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:39:42

Allah takes the souls at the time of their death, and those that do not die ˹He takes˺ during their sleep. Then He keeps those for which He has decreed death and releases the others for a specified term. Indeed in that are signs for a people who give thought.  

God takes the souls at the time of their death, and, He takes, those that have not died in their sleep, in other words, He takes them during sleep. Then He retains those for whom He has ordained death and releases the others until an appointed term, that is, until the time of their death. The one that is released is the soul ˹that possesses the faculty˺ of discernment, without which the soul ˹containing the force˺ of life is able to remain ˹temporarily˺ — but this cannot be the other way round. Truly in that, mentioned, there are signs, indications, for a people who reflect, and then realise that the One with the power to do this also has the power to resurrect — Quraysh, however, never reflected on this ˹fact˺.
القرآن:٣٩:٤٢

اللَّهُ يَتَوَفَّى الْأَنْفُسَ حِينَ مَوْتِهَا وَالَّتِي لَمْ تَمُتْ فِي مَنَامِهَا ۖ فَيُمْسِكُ الَّتِي قَضَىٰ عَلَيْهَا الْمَوْتَ وَيُرْسِلُ الْأُخْرَىٰ إِلَىٰ أَجَلٍ مُسَمًّى ۚ إِنَّ فِي ذَٰلِكَ لَآيَاتٍ لِقَوْمٍ يَتَفَكَّرُونَ  

{الله يتوفى الأنفس حين موتها و} يتوفى {التي لم تمت في منامها} أي يتوفاها وقت النوم {فيمسك التي قضى عليها الموت ويرسل الأخرى إلى أجل مسمى} أي وقت موتها والمرسلة نفس التمييز تبقى بدونها نفس الحياة بخلاف العكس {إن في ذلك} المذكور {لآيات} دلالات. {لقوم يتفكرون} فيعلمون أن القادر على ذلك، قادر على البعث، وقريش لم يتفكروا في ذلك.