There is a beautiful story in the Upanishads, the sacred vedic texts:
A rishi called Jadabharatha somehow became attached to a deer he had rescued. He was living the life of a renunciate but he got attached to this deer.
From morning till night, he used to spend his time taking care of that deer. When he was dying, he was not able to forget the animal. He started worrying about the deer, ‘Oh! Who will take care of the deer? What will happen to it after my death?’
When he died, in the next birth, he was born as a deer.
Beautifully the verse in the Upanishad says that whatever you think in your last moment, you become that!
Some people think very cleverly, ‘Let me live my whole life the way I want to live. In the last few moments, I will remember god and chant His name and enter heaven somehow.’ Please be very clear, only that which you thought of in your whole life, will come up when you leave the body. Don’t think that at that last moment you can play the game!
No!
Actually, when you leave the body your whole system will be in such agony, because eighty or ninty years of your life will be run through in a fast-forward mode. All that will be seen are the scenes being fast-forwarded. Whatever experience you had intensely, only that will come up before you. Your spiritual experiences will come up in multicolor.
Please understand that ‘thoughtless awareness’ is the strongest experience you can have in your life. Even for a single moment, if you had that experience, it is enough. Naturally, when you leave the body that will come up. That will act as a light and you will be able to move into the Consciousness.
One more thing is important to understand about the time of death. If a person did not die naturally but had died prematurely or committed suicide, and if he did not have the conscious experience before his death, he has to wait for the remaining years he might have otherwise lived before he can assume a new birth. The spirit will live on without a body.
For example, if at the time of taking this body one had decided to live in this body for ninty years and then committed suicide at the age of sixty, then for the next thirty years the person has to struggle without a body waiting for the next body to be entered into. If the person commits suicide trying to escape the hell he was undergoing in the body, he will be forced to undergo the same hell without the body. Just imagine how much more suffering this would be. That is why one should never consider suicide as a solution to problems in this life.
Why do people normally contemplate suicide? Because they think this life is a torture, a suffering. But if they commit suicide, they will realize that what they are going to go through will be a much worse torture.
It will be like this: if you have sweets in front of you, but you don’t have a tongue to taste or hand to take it and put it into your mouth, how much of suffering it will be! In the same way, the whole world will be in front of you, but you will not have the body to enjoy it when you float around waiting for your next body after having committed suicide.
source: Living Enlightenment