My first mask clearing outside the pool (i.e. during my cert dive) went terribly, but ended up teaching me a valuable lesson. This was 14 years ago but I'll never forget it.
I had been told time and time again during training, and on Scubaboard threads, not to pinch my nose when clearing my mask. I am a nose breather and this is very problematic for me because I have never mastered the skill of just 'closing my nose' however you wizards do it. So when I did the mask clear at 40 ft, when I took my first breath to start clearing, I breathed a bunch of water in through my nose and started coughing. I tried to correct this without pinching my nose and... breathed more water into my nose, making things worse. After the third breath of water through my nose my lizard brain told me enough was enough, it's time to go, and I signaled to the instructor I was going up. I felt like I couldn't even take in a breath at this point.... when I tried to breathe in, nothing happened. She told me no and to stay down, and I tried one more time, in vain, to take a breath. Water up nose, no air going into lungs. I signaled thumb up again and this time didn't wait for an answer. I performed a CESA just as trained, got to the surface, and belched a significant quantity of air in what was probably an impressive of a display as I'll ever make. I had been hyper ventilating, unknowingly, due to the stress and semi (mostly?) panicked state I was in. My lungs were probably pretty full, which is why I couldn't take a proper breath. From what I recall I *was* trying to exhale all the way up while still trying to get a sip of air because I was waaaay past having any normal kind of breathing at that point. There was still a lot of air left in there when I surfaced, though. I'm lucky I escaped without a lung injury.
The instructor directed me out of the water, let me calm down, and asked me if I wanted to try again. I explained the problem I'd had and she said "well pinch your nose then" (...dummy, was heavily implied). I returned to 40 ft after a 15 minute break and completed my drills without incident, nostrils firmly pinched for the mask clearing that she made me do twice.
She commended me later for dealing with my attempted self-drowning as well as I did. I didn't (fully) panic, properly signaled, and did a great CESA, according to her. Her coaching after that was where I got the valuable lesson. Long story short, she said it was good that I had my first 'panic event' right in front of an instructor, and was able to somewhat handle it properly. She said a lot of people panic for the first time in the open ocean and the results are less optimal. Her coaching taught me how to recognize when things were getting away from me underwater and just calm. the f. down. Then deal with the situation however I needed to, other people's rules (don't pinch your nose you weakling, you'll never be a real diver that way) be damned. I internalized that and it has helped me avoid panic in two other dives where I encountered very stressful situations. Due to this previous experience was able to recognize what was happening, control my fear, continue thinking, and resolve the issue without having to leave the water.
The incident made me a better diver in the long run. I still wouldn't wish it on anyone.

I have since learned how to kinda sorta not breathe through my nose when the mask comes off, but a hand is always ready to reach out and grab the schnoz if my nostril sealing skills fail me.