Chosen Solution
I suspect it is running hot in clamshell mode causing the overheat sensor to shut it down. Open it up and clean out the fan, remove it and clean the vent.
It can be an overheating problem. I would start from monitoring the cpu temp when it’s under load. And does this only happen when its on battery or does it still happen if its plugged in?
Experiencing exactly the same issue with the same model Macbook Pro 15”. I suspect there is something wrong with the onboard memory. Shutting down randomly, safe boot is much better than normal boot. OS will shut down in few mins in normal boot, however it might last few hrs in safe boot model.Running on battery or on power adapter seems doesn’t matter, shuts down all the same.No shuts down in Recovery Model or the process of installation.Seems not caused by overheating, also shuts down when wakes up from cold. @siner55 , not sure if you have fixed this issue after all? If yes, will you please enlighten how? Cheers.