Computer crashes when I play games?

So my laptop randomly shuts off on 2 conditions:
1. I haven't used it for a while
2. I'm playing games on it

So if I was to play something like ROBLOX, my computer crashes. If I played minecraft, however, my computer crashes in like 20 minutes.

My laptop is not overheating because I cleaned it less than a week ago. My best guess is because of a malware virus, but I'm not certain. I really need help. This problem is irritating me and it annoys me and sometimes, I feel like I need a new laptop. What do I do?

Mine used to do that to because the baterry was loose

So you assume it isn't overheating based on you cleaning it? Bad idea. It could have old and dry thermal compound/paste. The stock cooler could be failing. Those are only a couple possible issues. Use http://www.cpuid.com/softwares/hwmonitor.html (not pro) to avoid assuming. Coretemp is another real time monitor that also records min and max temps over the course of a session. You can alt+tab out of a gaming session to check temps. Using dual monitors to see real time info is better.

Go to start and type event viewer. See what errors have been recorded.

Best guess? Your laptop is old and weak.

There's either issues with how much you have used on your hard drive, and since your trying to write new data, is it getting corrupt. Or the folder is massive and keeps getting corrupt. Virus's won't specifically crash games and no other program. Virus's mostly screw up your computer. Like they make it slow. Download programs. Have a history of what keys you click. Etc