President Trump leaves at the end of a news conference following a meeting, earlier Thursday, with North Korean leader Kim Jong Un in Hanoi. (Luong Thai Linh/EPA-EFE/REX)

President Trump’s critics said he was too vain to walk away from a bad deal at his summit with North Korean leader Kim Jong Un. But that’s exactly what he did — and he showed himself to be a winner in the process.

The pre-summit conventional wisdom said this wouldn’t happen. Trump was supposed to “need” a deal to counter the publicity from his former personal lawyer Michael Cohen’s testimony before the House Oversight Committee on Wednesday. Trump was supposed to be too besotted with his personal relationship with Kim to refuse something that the clever dictator would present. Anonymous aides were said to be worried about what would happen if the two men were alone in a room together.

Well, they were alone in a room, Kim did offer a terrible deal, and Trump calmly walked away. Indeed, by cutting the summit short and walking away without even signing a face-saving concluding statement, Trump made it clear that he was more interested in substance than show.

Make no mistake, the deal Kim supposedly offered would have been terrible from a U.S. perspective. Dismantling North Korea’s nuclear facility at Yongbyon in exchange for ending all sanctions on the nation‚ as Trump portrayed their offer, would have given the North Koreans what they desired most for only a tiny portion of what we wanted. Even the North’s characterization of the offer, that they only wanted removal of some sanctions, would have been insufficient for the United States.

North Korea’s leaders would have kept all their intercontinental missiles, all of the weapons-grade plutonium already produced and all the nuclear devices they might have stored, and they would have kept their entire nuclear inventory secret. Indeed, offering to dismantle their only known source for plutonium is itself a hint that they have developed alternative sources, making Yongbyon expendable. No serious leader would even have considered such an offer.

Rejecting it out of hand shows that Trump was serious in this instance. “Sometimes you have to walk, and this was just one of those times,” the president said at a news conference. The fact that Trump could do that will send a clear message to Kim and other governments he is negotiating with that he won’t let ego get in the way of getting a good deal for the United States.

This in turn will bolster, not diminish, his popular standing at home. His backers will see their judgment vindicated: Trump took a risk, didn’t get what he needed and was shrewd enough to call off the meeting. Those who aren’t invested in their hatred for him might begin to see him in a different light. After all, they had just been told incessantly that Trump couldn’t do what he just did. Perhaps they will begin to see him as what he has always said he was: a negotiator who knows how to wield carrots and sticks, flattery and straight talk, as needed to get a deal done.

Make no mistake, a deal might still get done. Trump’s walking out does not mean talks with North Korea will cease. He was careful not to damn Kim, call for a return to “fire and fury” or start tweeting about “Rocket Man.” Instead, he simply stated that this deal wasn’t good enough and left, putting the ball back in Pyongyang’s court to see if its leaders are willing to move further toward the stated goal of denuclearization.

North Korea now knows the limits of its charm offensive. Firm resolve seems to underlie all the flattery and unctuous talk Trump has bestowed on Kim. The talk proved to be just that — talk.

We don’t know what will happen next. Perhaps all the critics will be proved right next time. Perhaps Trump only wanted a slightly less bad deal to sign. Perhaps the Cohen testimony had the opposite effect, convincing the president he would show more strength by walking away than by signing a deal when under political pressure at home. Perhaps.

Or perhaps, just perhaps, Trump really does know what he’s doing.

Read more:

The Post’s View: The Hanoi summit failure exposes Trump’s weak diplomacy

Jennifer Rubin: Trump’s utterly unsurprising diplomatic debacle

Erik Wemple: In Hanoi, White House embraces media despotism

Dana Milbank: Why does Trump fall in love with bad men?

Karen Tumulty: The most revealing insight of Michael Cohen’s testimony