BG Chap 8 - The state that determines one's next life
A person attains a state similar to whatever object he contemplates, under the control of previous remembrance, when leaving his body. Bharata, remembering a deer at the point of death, became a deer. Whatever one remembers at death is the subject of previous thoughts. His mind being controlled by that previous remembrance, he attains a body according to the object he contemplates at death. Thus by remembering Kṛṣṇa, one attains Him, and by remembering something else one attains something else. If in one's present life one lives in the mode of goodness and always thinks of Kṛṣṇa, it is possible for one to remember Kṛṣṇa at the end of one's life. That will help one be transferred to the transcendental nature of Kṛṣṇa. If one is transcendentally absorbed in Kṛṣṇa's service, then his next body will be transcendental (spiritual), not material.
If one worships the Lord as the governing principle of all material manifestation (adhibhūta), of the demigods (adhidaiva), and of all methods of sacrifice (adhiyajña), then he can know the Lord at the time of death. And whoever leaves the body remembering the Lord attains the Lord’s nature, with eight qualities: sinless, ageless, deathless, without grief, without hunger, without thirst, blissful, and his desires are instantly fulfilled. Remembrance of Kṛṣṇa is not possible for the impure soul who has not practiced Kṛṣṇa consciousness in devotional service. Therefore one should practice Kṛṣṇa consciousness from the very beginning of life. If one wants to achieve success at the end of his life, the process of remembering Kṛṣṇa is essential.