The story ends thus-- "Freed for ever from the bondage of ignorance through the touch of the Lord, the leader of the elephants attained a form similar to the Lord's; he was clad in yellow silks and endowed with four arms (Saroopya)"- (Bhagavada Purana 8.4.6.)
Looking at this episode allegorically, it can be said that the elephant stands for the 'ego' which is the result of the bondage of ignorance. This ignorance and its result, the ego, disappear by the grace of the Lord and the individual realizes his identity with the supreme Self, here described as attaining the same form as the Lord.
The individual, because of his ego, i.e. identification with his body due to ignorance of his real nature, is caught in the jaws of the crocodile, the samsaara. He can get release from this only by the Lord's grace. Neither his own efforts nor the help of others will save him from his false identification.
The elephant was, in his previous life as King Indradyumna, a great devotee and had mastered the Upanishads. The knowledge acquired in that life came back to him in his next life as an elephant, at the proper time. The Bhagavadgita says in verse 43 of chapter 6 that the knowledge acquired in the previous body continues in the next birth and enables the person to evolve further.
The crocodile which caught the elephant was in its previous life a Gandharva by name Hoohoo.Once, when the sage Devala was bathing in a river, Hoohoo went under the water and caught the sage by the leg. Since this behaviour was characteristic of a crocodile, the sage cursed him to be born as a crocodile. This story brings out the principle enunciated in the Upanishads that a person's next life will be determined by his actions and thoughts in this life. The Kathopanishad (2.2.7)
Sri SN Saastri(Advaita Scholar)
Having thoroughly understood the discussion between the Yamadūtas and the Viṣṇudūtas, he became a pure devotee of the Supreme Personality of Godhead. He lamented very much for how very sinful he had been, and he condemned himself again and again.
Finally, because of his association with the Viṣṇudūtas, Ajāmila, his original consciousness aroused, gave up everything and went to Haridwar, where he engaged in devotional service without deviation, always thinking of the Supreme Personality of Godhead. Thus the Viṣṇudūtas went there, seated him on a golden throne and took him away to Vaikuṇṭhaloka. source
PS- ,Afaik(from Sri SN Saastri s commentary on Narayaneeyam), the story goes as, Yamadūtas arrive early even before the tenure of Ajamila is over, owing to his sinful deeds. But Ajamila instantaneously gets the vairagya,.. a sudden purification of mind, (which is a rare case), whereas in general the natural tendency would be to fall back to earlier ways, closing the doors of emancipation.
No one can comment on how and when culmination of vairagya can occur to anyone.It happens ,when it has to.