
According to Islamic scholars, if a person is in the state of Sakarat (nearing death), those present with him should do Zikr, Tasbeeh, and Tahleel. This helps remind the sick person to also remember Allah. Reading Surah Yaseen or similar verses of the Quran at that time is even better.
If the sick person is not in the state of Sakarat, then doing Zikr and Tahleel in front of him is still allowed. After the person dies, it is Sunnah to continue doing Tasbeeh and Tahleel.
As mentioned by Allama Al-Jamal (رحمة الله عليه):
"It is good for those around the dying person to do Zikr aloud so that he remembers Allah. They should say together ‘Subhan Allah, Alhamdulillah, La ilaha illallah, Allahu Akbar.’ Reading Surah Yaseen in this situation and even after death is the best practice." (Hashiyat al-Jamal 3/122-123)