Dua for a Good Ending
Prayer
اللَّهُمَّ اخْتِمْ لَنَا بِحُسْنِ الْخَاتِمَةِ وَلَا تَخْتِمْ عَلَيْنَا بِسُوءِ الْخَاتِمَةِ
Meaning
O Allah, seal for us a good ending and do not seal upon us a bad ending.
Context & Explanation
According to https://muftiwp.gov.my/ms/artikel/irsyad-al-hadith/2278-irsyad-al-hadith-siri-ke-245-doa-mati-dalam-kebaikan, supplication is one of the greatest acts of worship as it connects directly to Allah SWT. Additionally, there is flexibility in supplication where we do not necessarily have to supplicate with the supplications taught by Allah SWT in the Quran or by the Prophet SAW in the hadith, although the best supplications or wording are those from Allah SWT and the Prophet SAW. We can supplicate with any supplication as long as its meaning or intent is good and does not contradict the religion.
Reference
No specific authentic hadith with exact wording