With his work done and his office closing, Robert Mueller could have quietly slipped back into private life. Instead, he gave himself a ­blowout retirement party — and leaves America to suffer the nasty consequences.

On his way out the door, Mueller pointed at President Trump and told Democrats to get him. In a flash, the next 18 months were ­spoken for.

If you doubt it, look at the way Dems reacted. Or rather, the way they erupted. From Congress to the 2020 campaign trail, they united in concluding that the special counsel encouraged them to nail the ­president.

California senator and presidential candidate Kamala Harris captured the moment by declaring, “What Robert Mueller basically did was return an impeachment ­referral.”

She’s right, and the fallout will be enormous — and destructive for the nation.

Whatever slim hope there was that Democrats would do something other than harass Trump instantly vanished. Mueller has usurped Nancy Pelosi’s role in setting the House agenda, and it now becomes impeachment first, impeachment last, impeachment ­forever.

There will be no major legislation on infrastructure, no bipartisan response to the border crisis. Impeachment obsession could mean Congress won’t take up the new North American trade deal, which promises to add further juice to the already-roaring economy.

Even stopgap spending bills could fall victim to Mueller madness. And imagine how China, North Korea and Iran, along with our allies, will view an expanded effort to dump Trump.

And over what? Mueller had two years and an unlimited budget to investigate the president, and didn’t find sufficient evidence he committed a crime. Yet now, 68 days after he submitted his report, he suddenly and without invitation injects himself back into politics by riling up the lynch mob. As he leaves the stage, it’s definitely exit left.

Mueller is apparently furious that his probe didn’t have more impact, and seems determined that the books not be closed. Apart from what he said, his decision to speak at all is telling.

Given his claim he would never say anything beyond the report, why assemble the press to make a tantalizing statement? If the report is his testimony, as he said, why make the point in such showboat fashion?

By protesting too much, he invites suspicion about his motive. By insisting he will say nothing new even if summoned by Congress, he begs for a subpoena.

The comparison to his friend Jim Comey is inescapable. Mueller has done exactly to Trump what Comey did to Hillary Clinton: trash him in public while declining to file charges.

Since Comey’s July 2016 appearance where he cleared Clinton but criticized her over the email scandal, the nation got a tutorial on the fact that prosecutors are not supposed to play talk show host and moral arbiter. You charge or shut up.

Now both men have violated that tradition, with Mueller compounding his error by creating a muddle about whether he would have charged Trump with obstruction absent a decades-old Justice Department regulation that says no sitting president can be indicted.

He described that regulation in detail Wednesday and said because of it, “charging the president with a crime was therefore not an option we could consider.” Added to another point he made, that “if we had had confidence that the president clearly did not commit a crime, we would have said so,” he seems to be signaling that his team would have charged Trump with obstruction absent the prohibition.

Yet on the question of collusion with Russia, Mueller said only that there was “insufficient evidence to charge a broader conspiracy,” and made no mention of the regulation.

Moreover, Attorney General Bill Barr told Congress that Mueller, in a March meeting attended by several people, said the regulation played no role in the decision not to charge Trump with obstruction.

Barr also said that, in failing to reach a decision on that issue, Mueller had left the decision to him, and that he and then-Deputy AG Rod Rosenstein concluded there was not enough evidence to bring a charge. Barr added that they found the evidence lacking even without the no-indictment regulation.

That Mueller is suggesting a different view now smacks of a feud between the longtime friends. Recall the letter he wrote to Barr in March, complaining the attorney general’s initial four-page description of the 448-page report “did not fully capture the context, nature, and substance” of it.

Barr called the letter a “bit snitty,” and it has all the earmarks of having been written just to be leaked. And leaked it was.

Another reason to be suspicious of Mueller is that he pops up just as Barr’s probe of the origins of the Russia probe is taking shape. Barr has called the probe anything but ordinary, saying that “spying on a political campaign is a big deal” and that he wants to get his arms around the reasons for it.

He has questioned the role of the intelligence agencies and the FBI, and mentioned the period between Election Day in 2016 and Inauguration Day in 2017, saying “some very strange developments” took place then.

Among them, he said, was the January 2017 briefing Comey gave to the president-elect about the Russian dossier and “the leaking of information subsequent to that meeting.”

Another element to consider is Trump’s declassification order covering investigation documents. Mueller is a career deep-stater and can’t be pleased about the decision to make them public. By coming out now, he gives Dems fresh talking points at a time when Trump ­increasingly looks like a strong bet for re-election.

So the battle is joined anew, with Dems fired up to go scalp hunting and Trump opening the Obama administration’s vault of dirty tricks. Coming weeks and months are certain to be a riveting spectacle consuming Washington and the media.

Meanwhile, the actual business of government, from creating prosperity to keeping the peace, will take a backseat, assuming an empty seat can be found.