Here are some ideas:

First of all, you should think of/imagine panic situations enough that you condition your first response to be STOP and STAY. (Yes, I know that sounds like a dog obedience class!) That also works if the situation is a wild animal; as I've mentioned a number of times on this forum, to a predator, if it runs, it's dinner!

Sitting down and brewing a cup of tea at the first sign of panic is an excellent idea. I once read an acronym for this, but I've forgotten it (so much for mnemonics!). Even on a dayhike, having an alcohol stove, enough fuel for a couple of boils, a small pot or metal cup and a couple of herbal tea bags make a delightful break even if there are no problems. (Thanks to phat for this idea!). In a panic situation, by the time you've gone through the motions of making and then drinking the tea, you should have calmed down considerably. You've also added to your hydration, which is always good, since dehydration can decrease your mental capacity.

One that was drummed into me in childhood was, "You're not lost, it's your car/camp/house that is lost."

Practicing these responses periodically is important!
_________________________
May your trails be crooked, winding, lonesome, dangerous, leading to the most amazing view--E. Abbey