Ibn 'Abbaas Radiyallahu 'Anhu reports that one of the daughters of Rasulullah Sallallahu 'Alayhi Wasallam was on her death bed. Rasulullah Sallallahu 'Alayhi Wasallam picked her up and put her before him. She passed away in his presence. Ummi Ayman (who was a slave girl of Sayyidina Rasulullah Sallallahu 'Alayhi Wasallam) began wailing aloud. Rasulullah Sallallahu 'Alayhi Wasallam said:
"Are you crying before the Messenger of Allah?" (because tears were also flowing from the eyes of Sayyidina Rasulullah Sallallahu'Alayhi Wasallam). She said: 'Do I not see you cry?' Rasulullah Sallallahu 'Alayhi Wasallam replied: "This crying is not prohibited. It is a mercy of Allah". (He softens the hearts of His servants, and creates love and mercy in them). Rasulullah Sallallahu'Alayhi Wasallam then said: "A Muslim is at peace at all times. even when his soul is being taken out, he is busy uttering the hamd (praises) of Allah".
English reference: Book 44, Hadith 308
Arabic reference: Book 45, Hadith 325