Allah says that Yusuf (Joseph, peace be upon him) said, which means,
“You are my Wali (Protector, Helper, Supporter, Guardian, etc.) in this world and in the Hereafter, cause me to die as a Muslim (the one submitting to Your Will), and join me with the righteous.” (Yusuf, 12: 101)
This supplication combined the acknowledgment of monotheism, submission to Allah, showing one’s need for Him, being free of taking any supporters other than Him, expressing that dying while being a Muslim is the greatest aim of any servant. This entails acknowledging that we are in the hands of Allah and not in the hands of any servant, confessing the truth of the Resurrection, and asking to join with the righteous.
The below is take from Tafseer Ibn Kathir:
Yusuf begs Allah to die as A Muslim
This is the invocation of Yusuf, the truthful one, to his Lord the Exalted and Most Honored. He invoked Allah after His favor was complete on him by being reunited with his parents and brothers, after He had bestowed on him prophethood and kingship. He begged his Lord the Exalted and Ever High, that as He has perfected His bounty on him in this life, to continue it until the Hereafter. He begged Him that, when he dies, he dies as a Muslim, as Ad-Dahhak said, and to join him with the ranks of the righteous, with his brethren the Prophets and Messengers, may Allah’s peace and blessings be on them all. It is possible that Yusuf, peace be upon him, said this supplication while dying.
In the Two Sahihs it is recorded that `A’ishah, may Allah be pleased with her, said that while dying, the Messenger of Allah was raising his finger and said – thrice, ثَلَاثًا (O Allah to Ar-Rafiq Al-A`la ﴿the uppermost, highest company in heaven﴾.) It is also possible that long before he died, Yusuf begged Allah to die as a Muslim and be joined with the ranks of the righteous.
Reference: Al-Fawaaid – A COLLECTION OF WISE SAYINGS