Chris Krebs knew his mission this year was to protect the integrity of the US election - but he might not have predicted the way that would cost him his job.
For well over a year, Mr Krebs and his cyber-security team had been gaming scenarios about what could go wrong. At one point, he said his greatest fear was that voter registration databases might be interfered with to stop people voting.
He also talked about the concern that on election night, media organisations might be hacked to prevent people knowing the results and create confusion.
The experience of Russian hacking and interference in 2016 had led the whole US national security community to prepare for a re-run in 2020. But in the end that was a threat that never materialised.
Perhaps that was because of the defensive work by Mr Krebs and colleagues or perhaps because of the way the National Security Agency went on the offensive against hackers in Russia and elsewhere to deter and stop them.
But it was also perhaps because foreign actors decided they did not need to do very much to stir up divisions - since they were so deeply entrenched inside America already.
The fear of misinformation led to the establishment of the Rumour Control website under Mr Krebs and this brought him into conflict with his own president.
Votes had been cast by dead people and were being counted. False, the site said.
A bad actor could change results without detection. Again, false, it said, providing details of why that could not be the case.
If results change in the days after the initial count, they cannot be trusted and have been compromised. Again, a big red cross on the website indicated this was not true.
This all directly contradicted assertions that Donald Trump and some of his allies were relying on to challenge the integrity of the result.
President Trump himself cited reports that a particular voting machine had deleted 2.7 million votes, while his campaign suggested dead people had voted in Georgia.
Mr Krebs' own Twitter account as well as the website maintained a steady and consistent message - the vote had not been rigged. A statement on 12 November by a group of officials posted on Mr Krebs' Cyber Security and Infrastructure Security Agency (Cisa) website described the election as "the most secure in American history".
"There is no evidence that any voting system deleted or lost votes, changed votes, or was in any way compromised," one line from the statement said - in bold to add emphasis. Less than a week later, Mr Krebs was "terminated" by a presidential tweet.
Mr Krebs was highly regarded within the cyber-security community.
"He built Cisa into a major player on the global cybersecurity stage," Ciaran Martin, who ran the UK's closest equivalent body until September, told the BBC.
"His work on election security is his crowning achievement. It brought together everything he'd built: the ability to harness elite national security capabilities to protect small local government bodies that run elections.
"And he fearlessly communicated the truth about what were real threats, and what weren't."
His firing was the latest - and not necessarily the last - chapter in the long battle between President Trump and his own national security community. At issue from the start has been the legitimacy of both election campaigns he has fought in.
His presidency began with him lashing out at his own spies for their assessment that Russia interfered in 2016 to support his candidacy. That began a long tussle in which the president almost appeared to see a zero-sum battle; one in which he sought to undermine the credibility of his own spies to avoid any question being raised about his victory.
The tension has ebbed and flowed, with some officials sacked and others walking a fine line to try and protect themselves and their own institutions.
But the 2020 election result has led it to explode again.
In 2016, Donald Trump was angry at claims there had been election interference. This time his anger is at the refusal of those like Chris Krebs to back up his claims that there was.
Mr Krebs is gone and with an uncertain, uneasy transition ahead, he may not be the last.