Bhagavad Gita 8.6
Whatever sphere of being the mind of a man is intent on at the time of death, to that he will go.
यं यं वापि स्मरन्भावं त्यजत्यन्ते कलेवरम्।
तं तमेवैति कौन्तेय सदा तद्भावभावितः॥yaṃ yaṃ vāpi smaranbhāvaṃ tyajatyante kalevaram|
taṃ tamevaiti kaunteya sadā tadbhāvabhāvitaḥ||
English translation (above): Shri Purohit Swami (1935), public domain. Sanskrit text via github.com/gita/gita (Unlicense).