@OP

Bad power supply or mobo, or maybe unstable overclock. If overclocked reset everything to stock. Test the PSU by unhooking all components and jump start it with a paperclip between the green wire and any black wire of the main connector and just let it run. If it shuts off after a while there's the problem. If not maybe it's mobo.

You could also keep an eye on CPU temps with software that has an audible alarm if it gets too hot. I doubt CPU overheating is the issue though because most CPU nowadays just throttle themselves back when too hot instead of shutting down completely.