I heard Messenger of Allah ﷺ saying, "No prophet gets sick but he is given the choice to select either this world or the Hereafter." ʿAisha added: During his fatal illness, his voice became very husky and I heard him saying: "In the company of those whom is the Grace of Allah, of the prophets, the Siddiqin (those followers of the prophets who were first and foremost to believe in them), the martyrs and the pious.' (4.69) And from this I came to know that he has been given the option.
سَمِعْتُ رَسُولَ اللَّهِ ﷺ يَقُولُ مَا مِنْ نَبِيٍّ يَمْرَضُ إِلاَّ خُيِّرَ بَيْنَ الدُّنْيَا وَالآخِرَةِ وَكَانَ فِي شَكْوَاهُ الَّذِي قُبِضَ فِيهِ أَخَذَتْهُ بُحَّةٌ شَدِيدَةٌ فَسَمِعْتُهُ يَقُولُ {مَعَ الَّذِينَ أَنْعَمَ اللَّهُ عَلَيْهِمْ مِنَ النَّبِيِّينَ وَالصِّدِّيقِينَ وَالشُّهَدَاءِ وَالصَّالِحِينَ} فَعَلِمْتُ أَنَّهُ خُيِّرَ