It's led to me becoming extremely, extremely cautious in avoiding gluten - after riding this lovely ride about once a month for the first 6 mos after I was diagnosed, I'm either irrationally phobic about gluten, or I've rationally decided no risk is ever worth feeling that way, depending how you want to look at it - but since I got super strict it's only happened once (freak contamination accident). It sucks for what it's done to the rest of my life, but it is no question so much better for me to avoid going through that, as much as I possibly can.
In terms of getting through it, here are the best tactics I've found, such as they are:
With the small rational piece of my brain that still works, remind myself as often as I can that this will pass, that it's a physical reaction, and that even though I can't conceive of it in that moment, I'll feel happy and sane and positive again in a few days.
Eliminate all obligations/activities/stress that I can for those few days. Stay home from work if I can, and try not to expect anything from myself until it passes. The only thing worse than having a completely broken brain is attempting to be a productive person or deal with any kind of difficult situations while I'm stuck with it. It took a while (I'm a bit type A by nature) but I try to accept and not blame myself for respecting my limitations when this happens.
Do something mindless, to try to occupy your brain while you wait it out. Seriously, Netflix has been a godsend for me at these times. I find anything I think about while my mind is in that state gets cast in the darkest possible way, and I can end up thinking awful, very upsetting thoughts if I give my brain any rein to wander. So I try to put on a documentary or whatever show I can think of to distract myself, and just keep letting the next episode play and trying to not let myself think about much of anything until I can fall asleep.
I wish I could be more help! I guess the best thing I can say is that it does always pass, eventually, and keeping safe from gluten is keeping my brain on track too : ) I'm normally pretty balanced and upbeat and have lots of fun and joy in my life without gluten - and I've been able to keep in that place pretty well for the last 6 months. I hope you get to a safer, happier place soon too : )