The Messenger of Allah ﷺ said, "When one of you rises from his bed and then returns to it, let him dust it off with the edge of his garment three times, for he does not know what may have come onto it after he left. Then when he lies down, let him say, 'In Your name, my Lord, I lay down my side, and by You I raise it. If You take my soul, have mercy on it, and if You send it back, protect it with that by which You protect Your righteous servants.' And when he wakes, let him say, 'Praise be to Allah who has restored my body to health, returned my soul to me, and permitted me to remember Him.'"
حدثنا ابن أبي عمر حدثنا سفيان عن ابن عجلان عن سعيد المقبري
أن رسول الله ﷺ قال إذا قام أحدكم عن فراشه ثم رجع إليه فلينفضه بصنفة إزاره ثلاث مرات فإنه لا يدري ما خلفه عليه بعد فإذا اضطجع فليقل باسمك ربي وضعت جنبي وبك أرفعه فإن أمسكت نفسي فارحمها وإن أرسلتها فاحفظها بما تحفظ به عبادك الصالحين فإذا استيقظ فليقل الحمد لله الذي عافاني في جسدي ورد علي روحي وأذن لي بذكره
[Sahih]. Nasai narrated it in Kubra, no. 10727, from the hadith of Ibn Ajlan through this route. Bukhari mentioned it without a full chain (muallaq), no. 6320. The hadith has multiple routes in Bukhari and Muslim, 2714/64, and elsewhere.There is also a narration on this subject from Jabir, apparently referring to the hadith in Nasai's Kubra, nos. 10689–10691, which Ibn Hibban graded sahih, no. 2362, and Hakim, 1/548, saying it meets the criteria of Muslim, a judgment with which Dhahabi agreed.And from Ayesha, apparently referring to the hadith that follows, or to what Nasai narrated in Kubra, nos. 10625 and 10700, and Abu Dawud, no. 5061.