The main reason a computer turns off without warning is overheating. If the CPU, processor or any other component gets too hot, the computer shuts off to protect all its components from the heat.
Overheating of a computer sometimes occurs when the computer experiences excessive use, such as when playing games. It may also occur if something blocks the air vents. It is possible to download software to monitor the temperature of a computer. Also, a user should ensure the air vents are in good condition. He or she should turn off the computer and spray compressed air into the PC's air vents to get rid of dust. If the problem persists, it is wise to take the computer to a professional.