SB 2.1.13

khaṭvāṅgo nāma rājarṣir
 jñātveyattām ihāyuṣaḥ
muhūrtāt sarvam utsṛjya
 gatavān abhayaṁ harim
Word for word: 
khaṭvāṅgaḥ — King Khaṭvāṅga; nāma — name; rāja-ṛṣiḥ — saintly king; jñātvā — by knowing; iyattām — duration; iha — in this world; āyuṣaḥ — of one’s life; muhūrtāt — within only a moment; sarvam — everything; utsṛjya — leaving aside; gatavān — had undergone; abhayam — fully safe; harim — the Personality of Godhead.
Translation: 
The saintly King Khaṭvāṅga, after being informed that the duration of his life would be only a moment more, at once freed himself from all material activities and took shelter of the supreme safety, the Personality of Godhead.
Purport: 

A fully responsible man should always be conscious of the prime duty of the present human form of life. The activities to meet the immediate necessities of material life are not everything. One should always be alert in his duty for attainment of the best situation in the next life. Human life is meant for preparing ourselves for that prime duty. Mahārāja Khaṭvāṅga is mentioned herein as a saintly king because even within the responsibility of the state management, he was not at all forgetful of the prime duty of life. Such was the case with other rājarṣis (saintly kings), like Mahārāja Yudhiṣṭhira and Mahārāja Parīkṣit. They were all exemplary personalities on account of their being alert in discharging their prime duty. Mahārāja Khaṭvāṅga was invited by the demigods in the higher planets to fight demons, and as a king he fought the battles to the full satisfaction of the demigods. The demigods, being fully satisfied with him, wanted to give him some benediction for material enjoyment, but Mahārāja Khaṭvāṅga, being very much alert to his prime duty, inquired from the demigods about his remaining duration of life. This means that he was not as anxious to accumulate some material benediction from the demigods as he was to prepare himself for the next life. He was informed by the demigods, however, that his life would last only a moment longer. The king at once left the heavenly kingdom, which is always full of material enjoyment of the highest standard, and coming down to this earth, took ultimate shelter of the all-safe Personality of Godhead. He was successful in his great attempt and achieved liberation. This attempt, even for a moment, by the saintly king, was successful because he was always alert to his prime duty. Mahārāja Parīkṣit was thus encouraged by the great Śukadeva Gosvāmī, even though he had only seven days left in his life to execute the prime duty of hearing the glories of the Lord in the form of Śrīmad-Bhāgavatam. By the will of the Lord, Mahārāja Parīkṣit instantly met the great Śukadeva Gosvāmī, and the great treasure of spiritual success left by him is nicely mentioned in the Śrīmad-Bhāgavatam.