Overheating is considered as one of the major causes of shutdown problems in laptops.
When any laptop runs, it generates heat and if it does not cool down, it may result in random shutdowns.
Thus, to get rid of this issue with your HP laptop, you should keep it on a flat surface and allow the fans underneath to work.
The use of cooling pads for laptops is also recommended. This helps in removing the excess heat.