Hardware failure and viruses are the primary reasons a computer shuts down unexpectedly. If you're not familiar with computer hardware, consult with an expert before troubleshooting the problem yourself. Most computers purchased at retailers offer some form of protection or repair guarantee if the problem starts during the warranty period.
Unexpected shut downs are difficult to diagnose because many internal components can be responsible. If the issue started after adding new hardware to the computer, the new hardware is likely to be the cause. Otherwise, each component (from the processor to the motherboard) may have to be removed and tested to find out which piece of hardware is causing the problem. A common reason for a computer to shut down unexpectedly is overheating. The computer processor is designed to shut down automatically if the temperature gets too high to prevent damage to vital components. Dust, sloppy cable management inside the computer case and broken computer fans most often contribute to overheating. If air cannot circulate through the case, heat can quickly build up. Although not as likely, a computer virus may also cause unexpected shut downs. Use an up-to-date anti-virus program to scan your computer regularly to maintain a virus-free computer.