If you want to listen to music or an audiobook on your iPhone or iPad before you go to sleep, you can have it turn off automatically using the clock app.