Issue
You are playing your favorite game and your computer shuts down, restarts or freezes ... quite annoying.
This generally comes from overheating of the processor or the graphics card, or a video card not powerful enough to run the games, obsolete hardware or drivers..
Overheating
You can check if your computer is not overheating by using the following softwares
In all cases clean the fans of your PC.
If the cleaning of the fans is not enough and the CPU overheats, consider changing the thermal paste between the CPU and fan.
It is possible to add other fans to better ventilate the computer, make use of a better cooling system or even leave the PC case open!
If your graphics card/CPU are overheating, you need: Reduce the load on the graphics card: lower resolution and details, disable anti-aliasing .. Force frequencies of the GPU and graphics memory via the utility software of your graphics card(increase the rotation speed of the fan). More information here.
Graphics card/processor don't meet minimum requirements
Generally this is the graphics card that is the main cause.
Read this FAQ Check compatibility of a game online.
If your graphics card/processor are outdated: Reduce the load on the graphics card . Force frequencies of the GPU and graphics memory via the utility software of your graphics card. Replace these components.
Update your operating system.
Update the driver for your video card to see if there are any improvements.
Power Supply
When using a custom built PC , it may happents that your power supply is able to power your hardware when used to their maximum limit! You should consider getting a better one.