While this doesn’t happen as often with more experienced grapplers, sometimes you cannot pry the arm free from your neck, but you can open their knee up in order to start to recover your guard. This is part of the default guard recovery program you should have running at all times in your half guard game. Against more beginner and intermediate level players, this happens when they simply forget about, or aren’t aware enough, of the possibility of you recovering guard. Against more experienced players, this happens during transitional movements and scrambles.
Here you should be prepared for something of a micro game to happen. Step one is to frame with the lower part of your forearm or your hand (depending on how far away their leg is) on the inside or top of their knee. This opens space for you to free your trapped leg. As soon as you start to open this space, many people will use their hand (the same one as the leg you are pushing) to try to push your knee back down or simply post on your knee so your progress is halted. There are solutions to these problems, but for now just realize that often this is the next step in your development. The general idea is to either block this hand from touching your knee or pull it off as soon as it does touch the knee. From there, your path is more clear to recover closed guard.