If you take to your bed, then perform ablution, lie on your right side and then supplicate (below)…If you then die, you will die upon the fitrah; so let these words be the last you say (before going to bed).
اللهُمَّ أَسْلَمْتُ نَفْسِي إِلَيْكَ، وَوَجَّهْتُ وَجْهِي إِلَيْكَ، وَأَلْجَأْتُ ظَهْرِي إِلَيْكَ، وَفَوَّضْتُ أَمْرِي إِلَيْكَ، رَغْبَةً وَرَهْبَةً إِلَيْكَ، لَا مَلْجَأَ وَلَا مَنْجَا مِنْكَ إِلَّا إِلَيْكَ، آمَنْتُ بِكِتَابِكَ الَّذِي أَنْزَلْتَ، وَبِنَبِيِّكَ الَّذِي أَرْسَلْتَ
Allaahumma aslamtu nafsee ilayk, wa waj-jahtu wajhiya ilayka wa ’alja’tu ẓahree ilayk, wa fawwaḍtu amree ilayk, ragh-batan warah-batan ilayk, laa malja’a wa laa manja minka il-laa ilayk, aamantu bi-kitaa-bika-l-ladhee anzalt, wa bi-nabiyyik-alladhee arsalt
O Allah, I submit my soul unto You, and I turn my face towards You, and I totally rely on You, and I entrust my affair unto You, in hope and fear of You. Verily there is no refuge nor safe haven from You except with You. I believe in Your Book which You have sent down and in Your Prophet whom You have sent.
(Sahih al-Bukhari 6311)