I've never been in such a situation. From what I've read, it often helps to have planned in advance. For example, if you routinely take note of all the exits from any indoor space you happen to be in. On an aeroplane, count the number of seats between your row and the nearest exit in front of you and behind you. Even if your advance plan turns out not to be usable, it at least forms a starting point and helps put you in a viable frame of mind.

Breathing. There are specific, ritualistic breathing exercises that can help restore calm. I have wondered if the Litany against Fear would help, but I have no evidence either way. Proper breathing has a deep physiological affect beyond the psychological.
_________________________
Quality is addictive.