I have an HP Envy 15t Slim Quad laptop which has a GTX 950M. I've had it since last November and didn't run into this issue until recently (about a month ago). Whenever I run something using the GTX the laptop sleeps within 2-5 minutes. It is especially weird since it even does this in a game like Minecraft (which does not at all require high performance) and even weirder it does this in all games with the exception of League of Legends. I thought maybe it was an OS issue (since bugging out in some but not all games didn't seem to me like a hardware issue) and before I even start testing a game, it happened again during a witcher 3 installer which had a high cpu usage (90% actually). I basically bought this laptop because at the time I couldn't afford a gaming PC and now I can't even game on it. Also relevant is the fan is always extremely loud within a minute of starting a game.
Sounds like you're overheating which is causing the laptop to sleep or shutdown. Download MSI Afterburner and monitor your CPU & GPU temps. You probably need to open up the laptop and blow out any dust that's accumulated.