This has never happened to me in all my time of owning my iPhone, but the screen completely locked up on me. I wasn't sure what to do, but I tried holding down the power button and then the home button for a few seconds and it forced the phone to shutdown. This doesn't seem to be very well documented so I thought I'd share!
So, if your iPhone ever freezes or locks up:
- hold down the power button
- press and hold the home button while still pressing the power button and after about five seconds it will power off.