بسم الله الرحمن الرحيم
(Fatwa: 1170/761/L=9/1434)
In the above mentioned case of death in accident, it is correct to take compensation from the company. If all the heirs of the deceased person give some amount from this amount to the mosque then it is allowed to take it and use for the mosque. As this amount is like diyat (blood money) in which the all the heirs have their rights and this amount shall be distributed among all the heirs as per their shares.
Allah knows Best!
Darul Ifta,
Darul Uloom Deoband
