What is it recommended for a sick person to do when his illness is terminal?
Question

There is a person who is sick with cancer, and the doctors have been unable to treat him successfully. He has left the hospital to spend his remaining time with his family. His condition is deteriorating daily. What do you advise him to do?
Praise be to Allah.Al-Nawawi said: 
The sick person should strive to have a good attitude and avoid arguing and disputing concerning worldly matters. He should bear in mind that this is the end of his time in the realm of deeds, and he should end it with good deeds. He should seek the forgiveness of his wife, children, all his family, neighbours and friends, and all those with whom he had dealings or with whom he was friends or had any kind of connection, and ensure that they hold nothing against him. He should focus on reading Qur’aan, reciting Dhikr, and reading stories about the righteous and how they were at the time of death. He should observe regular prayer and avoid impurity (najaasah), and take care of other religious duties. He should not accept the advice of those who try to turn him away from these things, for this is something with which he will be tested, and this person who tries to do this is an ignorant friend and a secret enemy. He should advise his family to bear his loss with patience and not to wail over him or to weep excessively. He should advise them not to do any of the bid’ahs (innovations) that are customarily done at funerals. He should ask them to make du’aa’ for him. And Allah is the Source of strength.