Even if it's their father, mother, brother or sister who has died, they are not to make themselves unclean, because their uncut hair announces their dedication to God.
However, if someone dies suddenly close to them, making them unclean, they must wait seven days, and on the seventh day when they are made clean again they are to shave their heads.