Hazrat Anas (may Allah be pleased with him) narrated that the Messenger of Allah (peace and blessings be upon him) said: None of you should wish for death because of any harm that has befallen him. If wishing for death becomes necessary, then he should say: "O Allah, keep me alive as long as life is better for me, and cause me to die when death is better for me."