If Americans should understand anything about Afghanistan after nearly 20 years of war in that country, it is that optimism is never, ever warranted. Not about victory, not about peace, not about anything.

On Friday, President Trump violated that rule:

On Saturday night, 63 people were killed in a suicide bombing in Kabul. Two hundred others were wounded. Once again, hopefulness in Afghanistan was punished in bloody fashion.

Many Americans have functionally forgotten that our country is at war in Afghanistan, but the people there certainly haven't. They live with the bombings and broken lives — The New York Times counted 20 combat-related deaths last week before the bombing — and they probably will continue to do so for some time after U.S. forces leave. Like the Soviet Union and the British Empire before it, the United States has learned the country cannot be "fixed." But it is also true conditions could be much worse.

Which means leaders in both countries are faced with a paradox. America is increasingly ready to leave Afghanistan — and it will do so eventually, whether by the end of this year or 20 years from now. But doing so could very well result in a moral disaster, particularly for women's rights.

In this generation-old war, it seems there are only bad choices and bad results left.

You cannot blame President Trump for wanting to leave Afghanistan. The United States has spent $1 trillion on the war there. More than 2,300 members of the military have died in that country — along with 1,700 civilian contractor deaths — and more than 20,000 others have been injured. Despite that cost, the war grinds on inconclusively despite (or perhaps because of) the presence of 14,000 American troops. The Taliban are mostly kept at bay from Kabul and other large cities, but it rules much of the countryside, and the official Afghanistan government remains largely powerless to protect itself or its people from attack.

It is conceivable that such a situation could go on in perpetuity. American troops have been in parts of Asia for more than 60 years. But troops in Japan and South Korea, for example, have carried out their missions in climates of relative peace — the prospect of being shot at or bombed isn't precisely zero for American troops in those countries, but it's close enough. At the moment, the continued U.S. presence in Afghanistan is a commitment to continued war — the expense of both blood and treasure.

That would seem to be reason enough to get out — killing and dying in an endless, unwinnable war is immoral — except for one thing: If and when the United States leaves, there is a pretty good chance the Taliban will, sooner or later, reassert its control over the entire country.

Two problems arise from that scenario. The first is that the Taliban would once again play host to the kind of international terrorists who attacked the United States on 9/11. The second is, again, the fear that women's rights would be severely compromised. Let's talk about the second issue.

If anybody has benefited from America's war in Afghanistan, it has been women, whose rights were severely curtailed when the Taliban ruled the country during the post-Soviet era. More than three million girls now attend primary and secondary school. More than 60 women have been elected to the country's parliament. Another 10,000 serve in the health-care field. Afghanistan's ambassador to the United States is a woman.

These are good and remarkable developments, and they have been made possible by America's armed power. Let the Taliban slip back into government, and there is a good chance that women's gains in education, health, and power will be suddenly erased. Again.

The Taliban have promised they are ready to observe women's rights. There is little reason to believe this is true — women who participate in Afghanistan's public life routinely face threats against their lives. It's true that continuing the war is immoral, but so is an unjust peace that foreseeably compromises the rights of women.

How do you choose between unacceptable outcomes?

Afghanistan's women are demanding a seat at the table for whatever peace agreement is eventually negotiated. That's a no-brainer. The U.S. should demand they also sign off on that agreement, or else no deal can be reached. And the United States should additionally offer guarantees of refugee status and asylum to women who flee the country if the Taliban fail to follow through on the deal. Even all that might not be enough.

Those last conditions are unlikely to sit well with President Trump, whose disregard for both women and refugees is by now legendary. He is right to seek peace in Afghanistan. But he shouldn't be allowed to claim a peace deal if it is made on the backs of women and girls in that country, who have already suffered and sacrificed so much over the generations. That means any peace deals should include protections for women that don't rely on the Taliban's good word for enforcement — even if that ends up being a deal-breaker. We have incentives to leave the country, but the Taliban has reason to want to see the United States leave. It's not a lot of leverage, but it might be enough.

There are no good options left to us in Afghanistan. Our obligation, after so long, is to do everything we can to ensure that leaving doesn't make the situation much worse. Optimism is impossible in Afghanistan. That's no reason to make a cynical deal in order to get out.