I hate when those dreams happen LOL.
Just like the first poster said when this happens, just relax. When you try to panic and get out of the dream it really won't work LOL. When this happens to me, all I really do is relax and let it pass, then wake up.
Plus thinking about it before you go to bed will only make it happen again. So when you go to sleep, try not to focus your mind on that happening again. Think about Ball pythons if that makes ya happy.