Requires iOS 7
For those who use music to fall asleep, Lullaby is a great addition to their device.
Lullaby, invoked through Activator, automatically shuts off your music after a certain period of time, such as after you've fallen asleep.
No longer will your phone be wasting battery and energy, playing music and using power all night long. Soon after you've fallen asleep, Lullaby shuts off your music for you!
Source available on Github.
Configure Activator from Settings.