Often the PlayStation will shut itself off if it's getting overheated. Make sure you give the console time to cool down after this happens, as you risk getting a Yellow Light of Death.
If you're getting this issue frequently, I'd recommend opening up the console and using compressed air to clean out any dust. You can use a guide like the fan replacement guide to help you open up the system.
If it happens infrequently, I wouldn't worry about it. It's happened to me before on long sessions of Little Big Planet Karting... that game is seriously addictive.