Bhagavad Gita · 16.22
एतैर्विमुक्तः कौन्तेय तमोद्वारैस्त्रिभिर्नरः।आचरत्यात्मनः श्रेयस्ततो याति परां गतिम्॥
etair vimuktaḥ kaunteya tamo-dvārais tribhir naraḥ ācharaty ātmanaḥ śhreyas tato yāti parāṁ gatim
A person who is freed from these three gates of darkness, O son of Kunti, practices what is good for the self and thereby attains the supreme destination.
— Bhagavad Gita 16.22
Source: Sacred-Texts.com (Sanskrit) + Bhagavad-Gita.io (translations)