I'm a bit late in this reply I guess, hope the OP is still around.
I guess jumping into conclusion isn't really fit into the situation.
I would like to offer different point of view, I'm with the OP on this. He doesn't really blame the instructor, and I don't think I would blame him completely and gives strong remarks that he has to quit bla ..
First thing that is very critical here of course is when he shut down the tank, without making sure that he already informed/the student have seen the signal. It could be confusing in limited visibility although he should make sure because it's very dangerous to shut down a student's tank.
But I can also say that he handle or at least tried to handle the rest of situation when the OP looked for air. As the OP said, he had the reg on his hand, but he was panic so he couldn't think to put in into his mouth.
I guess it's a very familiar situation that panic diver can't really think clearly. The reg was there, the instructor tried to give it to him but the OP didn't realize because he was panic.
The panic is fully understandable, it can turn a perfectly fine situation into chaos and fatality. It can affect other people also to think clearly.
We are solving it here in our desk in front of computer, not when my life is threaten, because not many people have the ability to handle emergency situation in real environment, as the example of the instructor. I'm not sure whether he had done it, but what he could do, he had to stuff the reg into your mouth and even hold it for you, because we have to assume the diver is too panic and would spit it out again. But again, it's a situation we never know how well we can handle it until we are there.
For me, for those who haven't have the same experience, talking about how you would react isn't the same when you have to react in real situation. We might be better, we might be worse, but discussing it certainly leave something useful in our memory that we at least have the knowledge if we can recall the solution when we are there.
I'm agree that you should talk to the instructor and discuss how you and him could do differently, I also agree that you can give him a second chance as he sound attentive and care. He went up with the OP and helped him in the surface. It did make a difference that he is still here today. Imho, instructor willing to learn from mistake can be the great one one day.
To answer the original question, I guess you have to work on your panic level. That's the root for many2 problem underwater. Be confident and calm enough to handle every situation by getting familiar with it. Dive confident first, in the place and situation you are familiar, built your skill and confidence in the water before you tried the more advanced environment.
Good luck and thanks for sharing.