Greetings,
Welcome to the forum.
I am not a HP employee.
Please remove the product serial number.
Your problem sounds like a thermal issue.
The CPU, GPU, or the motherboard may be getting really hot.
Test CPU temps by downloading the following portable software:
1. Prime95 (Link),
2. HWInfo (Link).
Run both programs (HWInfo will show all kinds of stuff) to test CPU temps, Motherboard temps, and, other parameters.
Test GPU temps by downloading Furmark (Link). Set Furmark to show real time GPU temps as the test runs.
Finally, the HP factory PSU may be the culprit.
I would contact HP (Link) for service if the above tests reveal thermal issues. I would contact HP if thermals are good because this means something else if going on.
HP Support will probably have you back up data and do a factory OS recovery to see if the problem persists.
Regards