The end of human depends on why they spent their whole life, this can be better understood by knowing why did jibreel (As) put mud in the mouth of Firhaun (pharaoh) when he was drowning in the Nile river.
It is narrated that Prophet Muhammad (PBUH) said that ‘When Allah drowned Firhaun he said ‘I believe that there is no god except the One that the children of Israel believe in.’ So Jibreel said ‘O Muhammad! If you could only have seen me, while I was taking (the mud) from the sea, and filling his mouth out of fear that the mercy would reach him.’
(This is narrated by Tirmidhi and similar narration is also narrated by Ahmad & Ibn Hibban due to which it is called hassan)
In Tafseer Al-Khaazin it is written that this act of Jibreel was according the command of Allah because angels follow the command of Allah.