Human beings sometimes crack, as the U.S. Army staff sergeant did last Sunday when he left his base outside Kandahar and began killing Afghan civilians in an apparent spasm of rage and frustration. But nations shouldn't crack. Even under the stress of a war that some days seems to be going horribly wrong, nations should move carefully so they don't leave more chaos and dead bodies in their wake.

Some of the recent events in Afghanistan show the American military mission at its worst: urinating on enemy dead; accidentally burning Qurans; a crazed soldier massacring civilians. We can say that most U.S. troops did nothing of the sort, and that such incidents are rare. But that doesn't change the reality that in such moments, we see how war can degrade decent men and nations.

The question for policymakers isn't the nature of war, but how to end it. And here, the gut reactions of this week are likely to be misleading -- in the sense that they could prompt hasty decisions that bring more loss of civilian life. A retreat under fire is dangerous in any case, but especially a pell-mell retreat that abandons previous strategies for withdrawal.

That's why Newt Gingrich's sudden conclusion that the war isn't "doable" is especially unfortunate. What did he think was possible here? If he was looking to force the Taliban to a USS Missouri-style surrender, he's in the wrong century.

President Obama has already said he intends to "responsibly wind down this war," as he put it Tuesday. He has agreed with NATO allies to transfer the lead combat role to the Afghans by the middle of next year and withdraw most foreign troops by the end of 2014. It's a plan framed by both the United States and its most important partners. It's not something for Americans to discard under duress because they're angry, aggrieved or even ashamed by recent events.

The U.S. strategy has been to shape the Afghanistan we will leave behind after 2014. Almost certainly, that country will be a mess. But as we discovered in Iraq, there's a difference between the out-of-control, homicidal mess of 2006 and the more controlled mess of 2011 when the last U.S. troops finally departed. The civil war that so many feared hasn't yet happened.

As in Iraq, the United States hopes to create conditions that can contain the disorder. That may sound like a fool's errand, but it's based on some sensible ideas: Build a good enough Afghan army to hold Kabul and maintain contact with the provinces; negotiate political power-sharing with the Taliban than can avert civil war; and work with Afghanistan's neighbors to build a firewall that can keep the inevitable violence there from destabilizing the region.

That's a hard strategy to pull off -- and even harder after Sunday's massacre -- but not an impossible one. It still looks better than the alternatives, which are guaranteed versions of civil war, partition or both. The administration also hopes to maintain a counterterrorism force to prevent al-Qaida from regaining a safe haven. That's a platform worth fighting for.

Thinking about how to end the war in Afghanistan, it's useful to consider the culture of our adversaries. The Pashtuns are good at starting wars, but they also have rituals for stopping them. The core idea is what the Pashtuns call "nanawatay," in which one of the combatants figuratively goes into the house of the other to settle the feud. A stable settlement is one with the balance of honor that Obama often describes with the phrase "mutual interest and mutual respect."

The diplomatic options are uncertain, like U.S. military operations on the ground. But they are part of a withdrawal strategy that looks well-reasoned even after last Sunday's disaster in Kandahar.