The Messenger of Allah ﷺ instructed a man from the Ansar to say when he lay down to sleep, "O Allah, I have submitted myself to You, turned my face toward You, entrusted my affair to You, and placed my back against You, in hope and fear of You. There is no refuge or escape from You except to You. I believe in Your Book which You revealed and in Your Prophet whom You sent." For if he dies, he dies upon the natural state of faith.
حدثنا عفان حدثنا شعبة عن أبي إسحاق قال سمعت
أن رسول الله ﷺ أمر رجلا من الأنصار أن يقول إذا أخذ مضجعه اللهم أسلمت نفسي إليك ووجهت وجهي إليك وفوضت أمري إليك وألجأت ظهري إليك رغبة ورهبة إليك لا ملجأ ولا منجا منك إلا إليك آمنت بكتابك الذي أنزلت ونبيك الذي أرسلت فإن مات مات على الفطرة
Its isnad is sahih. Muslim reported it, 4/2081, no. 2710, in Remembrance, Supplication before sleep. Tirmidhi, 5/468, no. 3394, and he graded it hasan, in Supplications. Abu Dawud, 4/311, no. 5046, in Manners. Ibn Majah, 2/1275, no. 3876. Darimi, 2/376, no. 2683, in Seeking Permission.