Computer always restarts after playing a game

I enjoy playing games using my computer. It's my past time and my way to relax.
But I think this is the cause of the computer error I encountered. I am just not sure if it is a virus or some computer error really. After playing a game with my computer, I would shut it down already.
But instead of it being shut down, it would restart automatically. It would go to the basic when turning on the computer, and would ask you if you would want to turn it on a safe mode. I would choose the normal mode but after pressing enter, it would simply turn off again. I don't know what's wrong or why it kept on going back like a loop.
The remedy I would do is turn it off by unplugging the CPU. When I turn it on again after a few minutes, it would function normally already. But once I play a game again, it would again go back to the same error. I am afraid that my computer would eventually break down because of this error. It only happens after playing a game with the computer. But if I just use it for surfing the net or other applications, it works just fine. Can you please help me fix this problem.
