Few days back I was facing a strange issue with my HTC Desire Z phone, it used to get switched of randomly!!
It was really frustrating to keep checking the phone to ensure it was alive.
I tried goggling but could not find much on the issue, meanwhile my better half was also trying to help me with the matter and she came across some video regarding restart loop on HTC phone. The video did not have solution to my problem but thanks to her attention to details, she scanned through few of the comments posted by people on the same video. It helped me to solve my problem.
So if your HTC phone is switching off randomly, give it a try to following mentioned steps and see if it helps,
2. Take out your SIM card
3. Start your phone without the SIM card
4. Switch off your phone again
5. Put the SIM card and start the phone again