He might use his magic skills. For instance, he could use a spell to break whatever force is keeping him in the middle position.
Perhaps he gets unstuck when he realizes a key detail or remembers a forgotten solution. Maybe it's a combination of physical effort and a sudden inspiration.
Maybe he calls for help using a spell that alerts his friends, like Hermione or Ron. They then come to his rescue and figure out a way to open the cupboard from the outside.
He could find himself in a really tough situation. For example, if he's in the middle of a feud between two magical factions in the fanfiction. He would have to use his wits and skills to try and find a way out or a solution that satisfies both sides. He might also start to question his own beliefs and loyalties as a result of being in this middle position.
If she's stuck in a physical space like a small hole or a tight corner, she can try to wiggle her body slowly. Sometimes a little movement at a time can help her get free.
Maybe someone pushed her from behind to get her through. Or pulled her from the other side.
Ino herself could use her own skills. Since she's a ninja, she could try to fight her way out if she's physically trapped. If it's an emotional or mental block, she could have an epiphany through self - reflection. Ino might remember her training, her goals, and her relationships, and that could give her the strength and clarity to break free from the situation she's stuck in within the fanfic.
Another way would be to seek help from other characters within the story who have some sort of meta - knowledge. There might be an old wizard or a super - intelligent alien who understands the nature of the stories they're in. Spider - Man could team up with them to figure out a solution. They could try to disrupt the flow of the story, for example, by creating a paradox. If they can make the story's internal logic break down, it might free Spider - Man from being stuck in the story.
She can try to gently twist and turn her foot to loosen it from whatever it's stuck in.
You could try starting a new novel. Sometimes getting into a different story can shift your focus away from the one you're stuck on.
She could try to wiggle her way out gently. If it's just a matter of being a bit wedged, some careful movement might free her.