Move setting sleeping status just before we actually might sleep

This makes sure we do this at the last possible moment.