When the Prophet ﷺ wanted to sleep while in a state of major ritual impurity, he would perform ablution as he did for prayer.
حدثنا مسدد وقتيبة بن سعيد قالا حدثنا سفيان عن الزهري عن أبي سلمة
أن النبي ﷺ كان إذا أراد أن ينام وهو جنب توضأ وضوءه للصلاة
Muslim narrated it, "Menstruation," "The permissibility of a person in a state of ritual impurity sleeping, and the recommendation of wudu for him," hadith 305, from Qutayba, with similar wording, and Nasai added, hadith 258, "and when he wanted to eat or drink," she said, "he would wash his hands, then eat and drink."