You can sometimes "sniff it out" by reducing the load on the power supply. Unplug the CD/DVD drives and see if it takes longer to shutdown.
Besides FANS, the heatsink under that fan will collect lint, dust and other insulating material. For most, a little over a year and the heatsink is clogged.
I have a HP Pavilion 8754C. It's a P3 800Mhz loaded with Win ME (ugh!) Anyway, it runs fine for about 20-30 mins. and abruptly shuts down. I hear a click and it's off. I ran it with the box open to see if it might be an overheating issue, but that did not help. Both the power supply and CPU fans are running fine. The power supply was replaced about 1 year ago, but honestly, it does not look like a new one. Physically it looks used. Is this a power supply issue? Or is something else involved?