When things have finally gone right
Yūsuf ﷺ said this at the height of it, reunited with his family and in power.
۞ رَبِّ قَدْ ءَاتَيْتَنِى مِنَ ٱلْمُلْكِ وَعَلَّمْتَنِى مِن تَأْوِيلِ ٱلْأَحَادِيثِ ۚ فَاطِرَ ٱلسَّمَـٰوَٰتِ وَٱلْأَرْضِ أَنتَ وَلِىِّۦ فِى ٱلدُّنْيَا وَٱلْـَٔاخِرَةِ ۖ تَوَفَّنِى مُسْلِمًا وَأَلْحِقْنِى بِٱلصَّـٰلِحِينَ
…fāṭira-s-samāwāti wa-l-arḍ, anta waliyyī fi-d-dunyā wa-l-ākhirah, tawaffanī musliman wa alḥiqnī bi-ṣ-ṣāliḥīn.
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 the Hereafter. Cause me to die a Muslim and join me with the righteous."
Where this comes from
After the well, the slavery, the prison and the years apart, at the moment everything was restored, what he asked for was to die a Muslim. Not for more of it to last.
Source
The Qur'an · 12:101
- Qur'anic text in the Uthmani script via Quran.com; translation: Saheeh International