When someone close to you is dying, you might find yourself going through a lot of emotions. People around you will ask you to be strong and tell you not to cry; it’s just your loved one’s time to go. You might be confused about what is and isn’t okay to do and how you should react. In reality, you’re a human being with feelings and instinctive reactions. Follow those reactions. It’s okay to be upset and it’s okay to cry. You’re not doing anything haram by expressing your sadness for your loss.
What is not allowed in Islam is wailing or loud screaming, tearing off of clothes, etc. Here is a beautiful hadith about how Fatimah (رَضِيَ االله عنْهَا) reacted when her father, Prophet Muhammad (صَلّى االلهُ عَلَيْهِ وسَلَّ) was dying:
وعنْ أَنسٍ رضِيَ االله عنْهُ قَالَ : لمَّا ثقُلَ النَّبِيُّ صَلّى االلهُ عَلَيْهِ وسَلَّم جَعَلَ يتغشَّاهُ الكرْبُ فقَالتْ فاطِمَةُ رَضِيَ االله عنْهَا : واآَرْبَ أبَتَاهُ ، فَقَالَ : « ليْسَ عَلَى أبيك آرْبٌ بعْدَ اليَوْمِ » فلمَّا مَاتَ قالَتْ : يَا أبتَاهُ أَجَابَ ربّاً دعَاهُ ، يا أبتَاهُ جنَّةُ الفِرْدَوْسِ مأوَاهُ ، يَا أَبَتَاهُ إِلَى جبْريلَ نْنعَاهُ ، فلَمَّا دُفنَ قالتْ فاطِمَةُ رَضِيَ االله عَنهَا : أطَابتْ أنفسُكُمْ أَنْ تَحْثُوا عَلَى رسُول االله صَلّى االلهُ عَلَيْهِ وسَلَّم التُّرابَ؟ روَاهُ البُخاريُّ.
Anas (May Allah be pleased with him) reported: When the last illness of Messenger of Allah (PBUH) made him unconscious, Fatimah (May Allah be pleased with her) exclaimed: "Ah, the distress of my dear father.'' He (PBUH) said, "There will be no distress for your father after today". When he died she said: "My father, Allah has called you back and you have responded to His Call. O father! Garden of Firdaus is your abode. O father! We announce to Jibril your death.'' When he was buried, she said: "Are you satisfied now that you put earth over (the grave of) Messenger of Allah (PBUH)?'' [Al-Bukhari]