There are certain things which a dying person should take into consideration:
A dying person should be satisfied with Allah's Fate and Destiny in order to get the reward of patience. It was reported in Sahih Muslim that the Prophet (peace be upon him) said: "How wonderful is the case of a believer; there is good for him in everything and this applies only to a believer. If prosperity attends him, he expresses gratitude to Allah and that is good for him and if adversity befalls on him, he endures it patiently and that is better for him." [Sahih Muslim No. 2999].
A dying person should beware of wishing death even if sickness and pain are hard because of the Hadith of Anas (may Allah be pleased with him) which was reported in Sahih Al Bukhari and Sahih Muslim that the Prophet (peace be upon him) said: "Let none of you wish for death on account of an affliction that befalls him. If he has no alternative, let him say: `Allahumma Ahyine ma Kanatil-hayatu Khairan li, wa Tawaffani Idha Kanatil-wafatu Khairan li (O Allah! Give my life so long as the life is good for me, and take away my life if death is good for me)'." [Sahih Al Bukhari No. 3651 and Sahih Muslim No. 2685].
It was reported in Musnad Imam Ahmad on the authority of Um Al Fadl (may Allah be pleased with her) that the Messenger of Allah (peace be upon him) said: "A person should not wish death for a harm that befalls him, but if he should do so, he may say: `Allahumma ahyine ma kanatil-hayatu khairan li, wa tawaffani idha kanatil-wafatu khairan li (O Allah! Give my life so long as the life is good for me, and take away my life if death is good for me)'." [Al Musnad 6/339, and Al Albany (may Allah bestow mercy on his soul) graded it as authentic in Sahih At-Targhib No. 3368].
A dying person should combine hope and fear in himself: Hoping for the mercy of Allah and fearing of His Punishment. At-Tirmidhy and Ibn Majah reported on the authority of Anas (may Allah be pleased with him) who said: The Messenger of Allah (peace be upon him) visited a young man who was dying. He asked: "How do you find yourself?" He said: "By Allah, O Messenger of Allah! I have hope in Allah. I am fearful because of my sins." Allah's Messenger (peace be upon him) said: "These two things (hope and fear) do not combine in the heart of a believer but Allah grants a person what he hopes for and protects him from what he fears." [Sunan At-Tirmidhy No. 905 and Sunan Ibn Majah No. 4351, and Al Albany (may Allah bestow mercy on his soul) graded it as authentic in Sahih Al Jami` No. 3383].
It is desirable for a person to write his will, and if he is indebted, he should render these funds back otherwise he should write the debt in his will so as not to waste them. It was reported in Sahih Al Bukhari and Sahih Muslim that the Prophet (peace be upon him) said: "It is upon every Muslim who possesses something for which he should leave instructions that he should not let two nights pass without writing a will about it." [Sahih Al Bukhari No. 2738 and Sahih Muslim No. 1627].
As for bequeathing something of his property for charity so that he may gain its reward after death, it is desirable and the lawgiver permitted him to do so at his death within the limit of one third of his property.
It is desirable for a person to commend his family with fearing Allah, keeping to His Commands, holding firm with the Sunnah of his Prophet (peace be upon him), and warning them against whims and heresies. Sa`id ibn Mansur reported in his Sunan on the authority of Anas ibn Malik (may Allah be pleased with him) who said: "People used to write in the beginning of their wills: In the name of Allah, the Most Gracious, the Most Merciful. This is the will of so and so, the son of so and so. I write the following: I bear witness that there is no god but Allah alone who has no partner and that Muhammad is His Servant and Messenger. Truly, the Hour is coming without any doubt and Allah resurrects those in graves. I commend my family to fear Allah, fix things up among themselves, and obey Allah and His Messenger if they are true believers. I commend them with the commandment of Abraham to his children and Jacob: "O my sons! Allâh has chosen for you the (true) religion, then die not except in the Faith of Islâm (as Muslims - Islâmic Monotheism)." [Surat Al Baqarah: 132] [Sunan Sa`id ibn Mansur P. 126, Print house, Ad-Dar As-Salafiyyah].
He should commend them to enshroud and bury him according to the Sunnah, and should warn them against heresies, especially if he has a hunch that they shall do so or seditions are widespread in his community. When death approached Abu Musa (may Allah be pleased with him), he said: "When you proceed with my funeral procession, go fast and do not follow me with an incense burner, do not put anything between me and dust, and do not build anything on my grave. I make you as witnesses for I am not responsible for any woman shaves her head, wails at me, or cuts her clothes for me. People said to him: Have you heard any Hadith in this regard? He said: Yes from the Messenger of Allah (peace be upon him). [Musnad Imam Ahmad 4/397, and Al Albany (may Allah bestow mercy on his soul) graded it as good in the rulings of Funerals P. 18].
We ask Allah for good end and to die as Muslims out of His Favor and Grace.