Bhagavad Gita · 8.6
यं यं वापि स्मरन्भावं त्यजत्यन्ते कलेवरम्।तं तमेवैति कौन्तेय सदा तद्भावभावितः॥
yaṁ yaṁ vāpi smaran bhāvaṁ tyajaty ante kalevaram taṁ tam evaiti kaunteya sadā tad-bhāva-bhāvitaḥ
Whatever state of being one remembers when leaving the body at death, that very state one attains, O son of Kunti, being always absorbed in that thought.
— Bhagavad Gita 8.6
Source: Sacred-Texts.com (Sanskrit) + Bhagavad-Gita.io (translations)