If you are facing a random shut down issues, the most likely reason is overheating. Please install some tool that monitors the PC temperature, especially while playing games. Overheating may send signal to the PC, which shuts down to prevent damage. I strongly recommend you to clean the cooling fans.
If you confirm that there is no temperature issue, I would suggest you to check the power supply, because it may be failing.