Based on the description I can't tell if it is a hardware issue, but one way to test would be to go under the Control panel and go to power options. There you can see what settings your computer has that it will turn off after a certain amount of time. I would try setting the time to turn off to "never" or "0" to see if the computer does turn off on its own. If it doesn't, then great, change the idle turn off setting to something you find acceptable. Otherwise if it does turn off even with the option turned off to never, then you may want to start looking at your hardware or maybe it could be power related.