Panic is often triggered by hyperventilating (quick, shallow breaths). So if you feel yourself losing it during the exam, sit back for a moment and control your breathing. Deep breath in and out through the nose, counting to five each way.
Steer clear of any exam 'post-mortem'. It doesn't matter what your mate wrote for Question, it's too late to go back and change your answers, so it will just make you worry even more. Ultimately, don't lose sight of the fact that there is life after exams. Things might seem intense right now, but it won't last forever.