We know that the mind is a process inside the brain. We know that because people with head and brain injuries experience personality disorders, memory loss, and in extreme cases, can become simply brain-dead vegetables. Severe brain injuries can often be irreversible, and the person rarely recovers full mental function. Now when that person is actually unplugged from the life-support machines, or when that person dies naturally, it would be quite a stretch to posit that they could actually regain their memories and cognitive abilities. If the person wasn't able to formulate thoughts while still plugged into the heart-lung machine, why would that person's condition improve after rigor mortis sets in?
If you say that a 'soul' leaves the body after death, does this soul have full mental capacity? Does the soul enter the afterlife (Heaven, Valhalla, Hades, or other) with all the cognitive power and memories from that person's life?
Then why doesn't the person who falls off a cliff and lands headfirst onto boulders below fully recover mental capacity once their broken bones have healed? Did that person's soul go away?
And when that person dies and becomes a ghost, or a soul in Heaven, does the soul come back with the memories? Where was that person's spirit?
The soul never goes away, because it does not exist. Brain death is final death of the individual. Anything that survives death becomes food for bacteria, mold, and worms. The mind cannot exist without the brain. The brain is part of the body. The body stays here in the physical world.
Treat your body well. It's the only one you have.