Their invasion has achieved nothing. When the US invaded, Afghanistan was a failed state, riven by civil war. And when they leave, Afghanistan will still be a failed state, riven by civil war. While Al Qaeda is gone, it was simply replaced by other terrorist factions elsewhere. Those have since declined, but the continued occupation of Afghanistan didn't have anything to do with that. Instead, it was just an effort by the US to avoid admitting defeat.
The good news is that to the extent that US occupation and torture are drivers of terrorism, any decrease in the US footprint will probably make the world a safer place. Now, if only they'd do that elsewhere.
(And meanwhile, there are still 40 prisoners languishing in Guantanamo. Only two have been convicted in the US's kangaroo court "military commission", another seven have been charged but never tried, and three more might be charged. As for the rest, they have never been charged with any crime, and are basicly being indefinitely detained without trial by the US. This continued injustice is a suppurating sore, and it needs to end immediately).