Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:3:144

Muhammad is not but a messenger. ˹Other˺ messengers have passed on before him. So if he was to die or be killed, would you turn back on your heels ˹to unbelief˺? And he who turns back on his heels will never harm Allah at all; but Allah will reward the grateful.  

With regard to their being routed, when it was rumoured that the Prophet had been killed and the hypocrites had said to the believers, ‘If he has been killed, go back to your ˹previous˺ religion’, the following was revealed: Muhammad is only a messenger; messengers have passed away before him. Why, if he should die or is slain, like others, will you turn back on your heels, will you return to unbelief (the last statement is the locus of the interrogative of denial, in other words, ‘he was not a worshipped being, so that ˹if he were to die˺ you should turn back ˹to your previous religion˺’). If any man should turn back on his heels, he will not harm God in any way, but will be harming himself, and God will requite those that are thankful, for His graces by staying firm.
القرآن:٣:١٤٤

وَمَا مُحَمَّدٌ إِلَّا رَسُولٌ قَدْ خَلَتْ مِنْ قَبْلِهِ الرُّسُلُ ۚ أَفَإِنْ مَاتَ أَوْ قُتِلَ انْقَلَبْتُمْ عَلَىٰ أَعْقَابِكُمْ ۚ وَمَنْ يَنْقَلِبْ عَلَىٰ عَقِبَيْهِ فَلَنْ يَضُرَّ اللَّهَ شَيْئًا ۗ وَسَيَجْزِي اللَّهُ الشَّاكِرِينَ  

{وما محمد إلا رسول قد خلت من قبله الرسل أفإن مات أو قُتل} كغيره {انقلبتم على أعقابكم} رجعتم إلى الكفر والجملة الأخيرة محل الاستفهام الإنكاري أي ما كان معبودا فترجعوا {ومن ينقلب على عقبيه فلن يضرَّ اللهَ شيئا} وإنما يضر نفسه {وسيجزى الله الشاكرين} نعمه بالثبات.