At a funeral why do they sometimes lower the coffin during the ceremony but other times do it after everyone has left Is this a religious preference or what?

i tdepends on the local custom, sometimes it is better for the family not to see the casket being lowered into the gravesite, and some families want to see the casket into the gravesite for closure