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:12:101

My Lord, You have given me ˹something˺ of sovereignty and taught me of the interpretation of dreams. Creator of the heavens and earth, You are my protector in this world and in the Hereafter. Cause me to die a Muslim and join me with the righteous."  

When he was nearing his end, realising that he would not remain ˹alive˺ forever, he longed for the everlasting kingdom and said: My Lord, indeed You have given me ˹something˺ of sovereignty and You have taught me the interpretation of events, the ability to explain dreams. Originator, Creator, of the heavens and the earth! You are my Protector, Guardian of my best interests, in this world and the Hereafter. Take me ˹in death˺ to You in submission ˹to You˺ and join me to the righteous’, from among my fathers. He lived after that for another week or more. He died at the age of 120 years. The Egyptians were very covetous with regard to his grave; ˹eventually˺ they placed him in a marble coffin and buried him at the top of the Nile so that both banks would be blessed ˹by his body˺ — Glory be to the One Whose Kingdom never ends.
القرآن:١٢:١٠١

رَبِّ قَدْ آتَيْتَنِي مِنَ الْمُلْكِ وَعَلَّمْتَنِي مِنْ تَأْوِيلِ الْأَحَادِيثِ ۚ فَاطِرَ السَّمَاوَاتِ وَالْأَرْضِ أَنْتَ وَلِيِّي فِي الدُّنْيَا وَالْآخِرَةِ ۖ تَوَفَّنِي مُسْلِمًا وَأَلْحِقْنِي بِالصَّالِحِينَ  

{رب قد آتيتني من الملك وعلمتني من تأويل الأحاديث} تعبير الرؤيا {فاطر} خالق {السماوات والأرض أنت وليي} متولي مصالحي {في الدنيا والآخرة توفني مسلما وألحقني بالصالحين} من آبائي فعاش بعد ذلك أسبوعا أو أكثر ومات وله مائة وعشرون سنة وتشاح المصريون في قبره فجعلوه في صندوق من مرمر ودفنوه في أعلى النيل لتعم البركة جانبيه فسبحان من لا انقضاء لملكه.