Overheating is the most likely culprit. PCs are designed to shut down automatically when heat endangers the hardware.
To find out if this is your problem, download and install Speedfan. It’s small and free. Although Speedfan’s basic job is controlling the speed of your PC’s fans (you probably guessed that by the name), it also provides the CPU temperature.
But that number is meaningless if you don’t know what’s too hot for your particular processor. Go to CPU World (no relation to PC World) for this information. Find your processor, select it, and scroll down the page. You’ll find the maximum operating temperature near the bottom.
You should also clean and check your PC to make sure it’s properly ventilated.
If your PC is a desktop:
Check the back and make sure that nothing is blocking the vents.
Open the case and check that the cables aren’t blocking the vents from the inside.
While it’s open, clean the insides with a bottle of compressed air.
Run the computer while the case is open. Make sure all of the fans are running properly.
And if you own a laptop:
Think about where you use it. Never run it while it’s sitting on a pillow or blanket, as these can block the vent.
Consider a laptop cooler. These special stands allow air to circulate below the PC. Actually, a sturdy cardboard box does wonders.
Blast compressed air through the vents.
If you’re unwilling to open your laptop and clean the insides, take it to a professional.