On DMG page 24, under "Bringing Back the Dead", it states that you cannot bring back the soul of an unwilling creature:
A soul can’t be returned to life if it doesn’t wish to be. A soul knows the name, alignment, and patron deity (if any) of the character attempting to revive it and might refuse to return on that basis. For example, if the honorable knight Sturm Brightblade is slain and a high priestess of Takhisis (god of evil dragons) grabs his body, Sturm might not wish to be raised from the dead by her. Any attempts she makes to revive him automatically fail. If the evil cleric wants to revive Sturm to interrogate him, she needs to find some way to trick his soul, such as duping a good cleric into raising him and then capturing him once he is alive again.
I quote the fact that the chapter says bringing back from the dead, and revivify states “You touch a creature that has died”.
Another thing to consider 5e is when a PC gets below 0 they go into death saving throws, which is the character fighting off death before dying.
From all that I assume the soul leaves the body the moment you die.
In my opinion, this rule also protects players from not being able to die when their character is super tired of things or done with life but circumstance keeps trying to bring them back. It has also protected me as a GM from player shenanigans.