If a person dies in a state of janaabah, that does not mean that he was weak in religious commitment or met a bad end, so long as he became junub for a permissible reason, such as intercourse with his wife or an erotic dream.
Hanzalah (may Allaah be pleased with him) was martyred when he was junub, and the angels washed him. His story is well known and was narrated by Ibn Ishaaq and others, as al-Haafiz Ibn Hajar said in Fath al-Baari.
Al-Tabaraani narrated from Ibn ‘Abbaas (may Allaah be pleased with him) that Hamzah (may Allaah be pleased with him) was martyred when he was junub. Ibn Hajar said: There is nothing wrong with its isnaad.
If a man dies in a state of janaabah, or a woman dies when she is menstruating, he or she should be given ghusl (washing of the deceased) only once. The ghusl for the deceased also suffices for the ghusl from janaabah or menses.
This is because there are two reasons for ghusl at the same time: janaabah or menses, and death. So one ghusl is sufficient for both, just as if there is more than one reason for wudoo’, such as passing wind and urinating, or sleeping deeply, then one wudoo’ is sufficient for all of them.
See: Kashshaaf al-Qinaa’ (2/87).
Al-Nawawi (may Allaah have mercy on him) said in al-Majmoo’ (5/123): Our view is that if a person who is junub or menstruating dies, they should be given one ghusl. This is the view of all the scholars except al-Hasan al-Basri who said: They should be given two ghusl. Ibn al-Mundhir said: No one else suggested this. End quote.
And Allaah knows best.