You may like to watch YouTube videos as you fall asleep, but if you do you've certainly noticed a huge glaring omission in the service's mobile apps. There is absolutely no way to make YouTube stop playing after a set time - there's no sleep timer. That's set to change soon. According to a teardown of the most recent version of the YouTube app for Android, a sleep timer is now finally in development, as evidenced by the strings in the screenshot below. As you'd expect, this will allow playback to stop after a specified period of time. If you haven't actually managed to fall asleep...
Source: https://www.gsmarena.com/youtubes_android_app_is_getting_a_sleep_timer_at_some_point_-news-63419.php