Random computer shutdowns are caused by either an overheating processor or a failure in the operating system. Fixing an operating system's registry fixes many random shutdown issues. For a potentially overheating processor, verify that a computer's fan is spinning at a consistent rate and that it is free from dust.
Registry errors are caused by installing, uninstalling and removing software from a computer. Some pieces of software overrule others, causing conflicts in how the system is told to operate. Running a registry cleaner can fix inconsistencies, preventing registry errors from causing random shutdowns. Take care to back up the registry as-is, however, just in case the software breaks the functionality of some of the programs. Not all registry cleaners are created equal and many others are paired with dubious promises.
For overheating issues, check to make sure that the fan is clean, spins freely and varies its RPMs with the workload and internal temperature of your computer. A computer's task manager reports the internal temperature of a computer. The more open and running programs, the higher the temperature gets. Remove the computer case, and verify that the interior is clean. Do not use canned air to clean the fan and heat-sink areas. This forces dirt and dust into the sensitive areas of the computer. Instead, use a vacuum hose with a narrow nozzle, taking care not to disturb or touch any of the internal components.