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:6:60

And it is He who takes your souls by night and knows what you have committed by day. Then He revives you therein that a specified term may be fulfilled. Then to Him will be your return; then He will inform you about what you used to do.  

It is He Who takes you at night, seizing your spirits during sleep, and He knows what you commit, ˹what˺ you earn, by day. Then He raises you up therein, that is, in the daytime, by restoring your spirits, so that an appointed term, namely, the term of life, may be accomplished; and afterward to Him is your return, through resurrection. Then He will inform you of what you used to do, and so requite you for it.
القرآن:٦:٦٠

وَهُوَ الَّذِي يَتَوَفَّاكُمْ بِاللَّيْلِ وَيَعْلَمُ مَا جَرَحْتُمْ بِالنَّهَارِ ثُمَّ يَبْعَثُكُمْ فِيهِ لِيُقْضَىٰ أَجَلٌ مُسَمًّى ۖ ثُمَّ إِلَيْهِ مَرْجِعُكُمْ ثُمَّ يُنَبِّئُكُمْ بِمَا كُنْتُمْ تَعْمَلُونَ  

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