I have had so many that I have a routine.
Ask the technician to talk you through the test, as in to say, "This part is 3 minutes," or ,"we have a few left to go," it really helps a ton with not feeling isolated. Twice I had oddball techs years ago who claimed to have no idea what I was asking for so I calmly explained it and they accommodated me, but most know precisely.
Have a favorite Pandora or Spotify station in mind you can sing along with when you notice what song is on, last one I asked for Pink but Bee Gees is fun too because I know all the songs. Now you won't be able to hear it very clearly because the machines make a racket but I tend to fill in the noisy spots by following along with the music bast as I remember, this also helps whittle away the time.
I haven't had the thing on my head in a long while but if they give you one do ask for a mirror and stare at the little mirror out into the room. I prefer the head thing with the mirror to be honest, last time I didn't get one and I wished I had it.
As for an emergency, they should he handing you a little buzzer, I have always had a buzzer. Also, the tech should be looking at you during the test, there is a little camera on your face so they can observe you.
Skip coffee to reduce angst.