on a working PC, prepare a Memtest 86 flash drive, boot from it instead, and run a RAM test for an hour or two...
Is this a desktop? Post some more specs besides just "HP CPU"
Jump into the BIOS, look for anything pertaining to system health with CPU temps, fan speeds, (many rigs demand to see some sort of CPU fan present) etc., and see if it is stable even in just the BIOS...
(Certainly, hard power-offs could be easily indicative of a failing PSU as well...)
If you have 2 RAM sticks, try just one alternately...that will rule out a failing RAM stick, although RAM would pretty rarely cause a rig to power off vice simply lock up, or blue-screen, etc...