This message is for all with an old iPhone shutting down randomly. I made a post earlier, suspecting the OS to be the fault. It seems not to be the case. My iPhone shuts down randomly, starting around 50 % back on the battery. It would only start when put in the charger. Just laying on the table, it would use up the battery in at single day (16 hours), and then shut down. At 8 £ or 12 $ I bought a new battery. It was quite easy to change, but may be I was just lucky. But after installing the new battery, the iPhone has behaved perfectly. Before it went dead during games. It also shut down trying to start an app if the battery was low.
The phone is a 3Gs. It is 3 years old and has been used by me for work and my kids for gaming. So maybe its no wonder the battery went dead. Funny though - you cant find much about that on the internet, but may by I´ve been looking the wrong places. Hope it helps and sorry if anybody already has given this answer.