If your computer is infected with malware, it may shut down by accident while you're playing games. Check if your antivirus software is up to date. To avoid malware interfering with your computer's normal operations, run a malware scan.