the HP laptops have a very poor cooling fan and, heatsink.
A common problem is: overheating and, intermitent shutdown / restart.
first; do not sit your laptop on a flat surface get a cooling pad for it.
if you want to and, can fix your laptop the HP answer is: flash the bios with the new bios that hp provides to make your fan run at low speed constantly.
I however have used a micro transformer of 18.5 (20) volts direct current + or, =
(plus or, minus) to 12 vdc fan side.
This 'fix" is somewhat loud and, reduces battery run time but is the only one that really works.
Never reformat your harddrives to fix a power problem as they are a totally different system in your laptop.