The decision to withdraw American troops from Afghanistan has been agonizing. But that was the easy part. The hard part begins when the country's capital falls to the Taliban, which it likely will within weeks or months of our soldiers returning home.

That's when Joe Biden's fateful decision will face its first real test.

Too many critics of American foreign policy fail to grapple with the fact that we usually aim to do the right thing. Yes, we have an itchy trigger finger. Yes, we're control freaks, trying to impose our vision of international order on a recalcitrant world and backing it up with drone strikes, special ops, and the threat of far worse. From the outside, this can look like brutal power politics, and at one level it is. But viewing it that way fails to capture the psychology and moral calculus of those who formulate and oversee the implementation of American policy abroad. We desperately want to believe that we do what we do, and kill whom we kill, not just for our own good, but for the good of everyone else as well. Maybe not in the heat of battle or in the midst of an occupation, but in the final analysis, at the end of our actions, the outcome is supposed to be a better world, with greater justice, more individual freedom, and more democracy.

Such considerations are the only way to explain how we've ended up where we are in Afghanistan. We invaded shortly after the 9/11 attacks with two limited goals in mind: decapitating Al Qaeda (including capturing or killing Osama bin Laden) and toppling the Taliban government that had allowed the group to use the country as a launching pad for terrorism targeting the United States. The second goal was accomplished very quickly. The first took far longer — nearly a decade — because bin Laden escaped into the mountains and managed to elude capture in Pakistan. But this goal, too, was finally achieved in May 2011.

While the hunt for bin Laden dragged on, the American military took on numerous additional goals. Before we knew it, we were committed to transforming Afghanistan into a functional, stable democracy with a military and police force capable of standing up to and fighting back against the Taliban's unceasing efforts to exert and expand control over parts of the country. This aim also required fighting corruption. And providing education for girls and opportunities for women. And working to grow the economy. And fighting the drug trade.

In the process, Afghanistan became an American vassal state. Life improved for many, especially women, at least in those parts of the country under direct government control. But the improvements have depended entirely on American back up. After nearly 20 years, there is little evidence that the local authorities alone will be capable of defending against a Taliban onslaught against Kabul. This means American withdrawal is highly likely to result in a reversal of all the goals that have been added to the mission over the years.

That, in effect, is what Biden was saying in his speech on Wednesday officially announcing the intent to withdraw all troops from the country (aside from a limited number of soldiers left behind to secure the American embassy in Kabul) by the 20th anniversary of 9/11 in September. The message was that we succeeded in achieving our original goals years ago, we've failed to achieve the additional ones, there's no realistic path to changing this outcome, and so it's time for America to come home and stop trying to do the impossible.

This is perfectly reasonable.

The trouble is that nations, like individuals, are often less than reasonable. The belief that we could turn Afghanistan into a stable, functioning liberal democracy wasn't reasonable. The belief that we could transform it into a place where girls and women enjoy freedom and equality wasn't reasonable. The belief that we could stamp out corruption and end the opium trade wasn't reasonable. These beliefs and goals were admirable, decent, well-meaning, and moral. We affirmed them because something deeply rooted in the American national psyche wants to do the right thing. That impulse is commendable, but reason has nothing to do with it.

How are Americans likely to respond when the Taliban begins an offensive against the capital, building on its territorial gains around the country in recent years, and eventually topples the democratically elected government we midwifed and defended and propped up for so long? Some will no doubt shrug their shoulders and callously dismiss it, claiming it just shows the Afghan people were never capable of democracy in the first place. But many others in positions of power in and around Washington D.C. will be utterly mortified. I told you so. If we'd stayed, this wouldn't be happening. This is on us. We are responsible. We have to make it right.

Shame, guilt, self-loathing, the urge to atone and repent, the craving for expiation of sin — these are powerful emotions, many of them with theological roots, and America is a country of intense, theologically grounded passions. Is Biden prepared for this reaction? Does he have a response ready at hand? I certainly hope so, because he's going to need one.

I'm not talking primarily about those on the right who will happily use images of a triumphant Taliban to score political points against a president and a party they need to take down in order to regain power. I mean those who will be genuinely appalled that two decades of expending American blood, treasure, and toil in Afghanistan have, in moral terms, come to nothing — or worse than nothing. We gave its people a taste of something better and then precipitated its collapse. That's an awful outcome, which isn't the way the story of America's military exertions is supposed to end, even though it does more often than most of us are willing to admit.

If Biden can successfully ride this tiger — continually reminding the American people and its foreign policy establishment that nations wishing to become liberal democracies need to be capable of exercising independence from the United States, that achieving this goal is extremely difficult and not at all predetermined or inevitable, that our country has neither the will nor the capacity to execute a policy of benign imperialism, and that pursuing our national interests demands more than doing good deeds in the world — he just might succeed in keeping us from making the same mistake in the future.

But if he fails — if our outrage at what transpires in Afghanistan following our departure overwhelms the president's efforts to tamp it down — then our actions on the world stage could become even more erratic than they have been over the past two decades. We could be tempted to seek national redemption by returning to Afghanistan to punish the Taliban. Or, worse still, we could seek to assuage our battered national conscience by looking elsewhere in the world for different monsters to destroy.

That would be a terrible mistake. But we've done it before. It would be foolish to presume we won't do it again.