Messenger of Allah ﷺ said to me, "When you want to go to bed, perform ablution as you do for prayer, then lie down on your right side and say: 'Allahumma aslamtu wajhi ilaika, wa fawwadtu 'amri ilaika wa alja'tu dhahri ilaika, raghbatan wa rahbatan ilaika, la malja'a wa la manja minka illa ilaika. Amantu bikitabik al-ladhi anzalta wa binabiyyika al-ladhi arsalta'. If you should die then (after reciting this) you will die on the religion of Islam (i.e., as a Muslim); so let these words be the last you say (before going to bed)" While I was memorizing it, I said, "Wa birasulika al-ladhi arsalta (in Your Apostle whom You have sent).' The Prophet ﷺ said, "No, but say: Wa binabiyyika al-ladhi arsalta (in Your Prophet whom You have sent).
قَالَ رَسُولُ اللَّهِ ﷺ إِذَا أَتَيْتَ مَضْجَعَكَ فَتَوَضَّأْ وَضُوءَكَ لِلصَّلاَةِ ثُمَّ اضْطَجِعْ عَلَى شِقِّكَ الأَيْمَنِ وَقُلِ اللَّهُمَّ أَسْلَمْتُ وَجْهِي إِلَيْكَ وَفَوَّضْتُ أَمْرِي إِلَيْكَ وَأَلْجَأْتُ ظَهْرِي إِلَيْكَ رَغْبَةً وَرَهْبَةً إِلَيْكَ لاَ مَلْجَأَ وَلاَ مَنْجَا مِنْكَ إِلاَّ إِلَيْكَ آمَنْتُ بِكِتَابِكَ الَّذِي أَنْزَلْتَ وَبِنَبِيِّكَ الَّذِي أَرْسَلْتَ فَإِنْ مُتَّ مُتَّ عَلَى الْفِطْرَةِ فَاجْعَلْهُنَّ آخِرَ مَا تَقُولُ فَقُلْتُ أَسْتَذْكِرُهُنَّ وَبِرَسُولِكَ الَّذِي أَرْسَلْتَ قَالَ لاَ وَبِنَبِيِّكَ الَّذِي أَرْسَلْتَ