yam yam vapi smaran bhavam
tyajaty ante kalevaram
tam tam evaiti kaunteya
(Attaining the Supreme ,Text 6, Chapter 8)
Meaning: Whatever state of being one remembers when he quits his body, O son of Kunti, that state he will attain without fail.
Bhagavad Gita: Process of changing one’s nature at the critical moment of death (Attaining the Supreme, Text 6, Chapter 8)