Life's but a walking shadow, a poor playerThat struts and frets his hour upon the stage,And then is heard no more.It is a tale Told by an idiot, full of sound and fury,Signifying nothing.― William Shakespeare, Macbeth
We can debate if the cost of remaining was worth-it to the US national interest. I think it was clearly worth it to have a secure base of operations next to the Stans, Iran and Pakistan. We could have kept this up for 100 years and had a side benefit of an excellent training ground for our military.
The analogy I return to, is the idea of giving a diabetic insulin. If you give the treatment for 20 years, the patient lives a fairly normal life. If you suddenly decide to stop providing insulin, he will quickly become ill and die--which is sad and unnecessary and shouldn't be done. But say it was done. He gained 20 years of life that he wouldn't have gotten, had you never provided the medicine.