Set music to stop automatically when you fall asleep
To make music shut off after a while when falling asleep, set a timer in the Clock app and select "Stop Playing" at the bottom of the When Timer Ends menu.
This works for all apps using the iPhone player.