They were being beaten back for at least the last three years that I was following it. They didn't just leave voluntarily, they were defeated and left early to save face. Check a timelapse map of the Taliban's territorial gains and consider that recapture of the entire country took them only two weeks.