SB 11.18.12

yadā karma-vipākeṣu
 lokeṣu nirayātmasu
virāgo jāyate samyaṅ
 nyastāgniḥ pravrajet tataḥ
Synonyms: 
yadā — when; karma — by fruitive activities; vipākeṣu — in all that which is obtained; lokeṣu — including promotion to all the planets of the universe up to Brahmaloka; niraya-ātmasu — planets that are actually hellish, being material; virāgaḥ — detachment; jāyate — is born; samyak — completely; nyasta — giving up; agniḥ — the sacrificial fire of vānaprastha; pravrajet — one should take sannyāsa; tataḥ — at that point.
Translation: 
If the vānaprastha, understanding that even promotion to Brahmaloka is a miserable situation, develops complete detachment from all possible results of fruitive activities, then he may take the sannyāsa order of life.