Here's a very simple tip for using the iPhone and iPod Touch on a "sleep" timer when listening to music.
Open the Clock app and choose the Timer feature. Choose how long you'd like the device to stay on, and for the "When Timer Ends" setting, choose "Sleep iPod/iPhone". This will cause whatever app is running when the timer occurs to stop, even if the display of the iPhone/iPod is already shut off. It's quite handy if you are listening to music or using a third party app that provides streaming media and you want the iPhone/iPod to auto quit after a certain period of time.
I've seen several cases in iPhone forums where people have been requesting this feature in various apps, so I assume it must not be a well known that this feature is already built into the iPhone / iPod Touch.