Gotta agree with CHA-LEE... Especially considering what you can buy for cheap nowadays...

Otherwise,

Does it smell warm/hot before it shuts down?
- It might be harder to smell if you have all the sides on it, so next time it does it, try and get a whiff.

If it smells hot. It will likely be the power supply.
If not, check that all the fans run, especially the processor fan.