Read this. Is this what is happening to you?
Also, while reading, I read this:
That happened to me a few times, too. Apparently (at least in this instance) you can't switch out, use items, or even Struggle. I think it happens mostly if you send out a low-leveled Pokémon against a much higher-level Pokémon. Here's a link
It sounded as if this was your scenario. He/she then posted a link, which linked to a Youtube video. Here's the video, if you care.
Just read/watch everything I gave you - did these scenarios happen to you? Because if so, there was no way you could get out and you just had to go back to where you last saved. If these are slight variations of what happened to you, it doesn't really matter if it hasn't majorly affected your game. Sorry about that.
Hope I helped. :)
Source: Above Links