I got stuck in the 6th gym. I saved before fighting the gym leader, my Gardevoir fainted from a critical hit, and so I closed without saving. When I reopened, the electric gates had reset and so I was trapped behind them with the gym leader and there were no switches where I was to deactivate them.