Turrnof by ittself

It's probably overheating & therefore shutting down to prevent permanent damage to the vital components. Playing games generates more heat than in normal PC usage, and your PC may not be suitable for heavy use. If it's a PC you can fit more cooling fans or use it with sides removed. If it's a laptop, there's nothing you can do except stop playing games on it and buy a games console instead.