When Gov. Andrew Cuomo pushed New York City Transit President Andy Byford out the closing doors, he also slammed them on the nearly 5.8 million of us who use the subway every day.

Andy, we hardly knew ye. But Andrew, we know you all too well.

Byford wasn’t here long enough to completely turn around the failing system — although he made a huge difference in his less than two years on the job. On the other hand, Cuomo — a self-proclaimed “car guy” with little interest in mass transit — has been governor long enough for us to know what to expect from him when an agency head overshadows his own imagined glory: namely, the boot.

Byford’s exit, prompted by Cuomo’s destructive MTA meddling, was inevitable. Rule No. 1 in New York state and city’s venomous politics: Don’t put your face ahead of the chief. Public appearances by subordinates, especially on TV, guarantee that the governor or the mayor will either fire the transgressor or make him so miserable he’ll have no choice but to leave.

The Byford story has a prequel. Cuomo had barely moved into the Albany governor’s mansion in 2011 when he fired then-Port Authority Executive Director Christopher Ward. Just like Byford, Ward did the seemingly impossible: in his case, kick-starting long-stalled World Trade Center reconstruction in his three years at the helm from 2008-2011.

Cuomo couldn’t stand Ward’s TV visibility or the way he shook up the Kremlin-like PA. If Cuomo hadn’t dumped him in favor of ineffectual technocrats, the Oculus might never have leaked.

Shouldn’t we credit Cuomo for hiring Byford in the first place? Sure, but the governor’s grace ended when Byford turned out to be too good.

To Cuomo’s chagrin, New Yorkers took a swift liking to Byford, a tireless and task-obsessed Englishman with a gentle accent that somehow gave us more confidence in the subways than any home-grown voice.

His empathetic tone struck a nerve with riders fed up with empty promises and cold prognostications of doom by out-to-lunch MTA talking heads and transit union hacks.

“Train Daddy,” as Byford came to be called, previously worked on subways and railroads in Toronto, London and Australia. But when he talked about improving recalcitrant signals on the B and D lines, he was the most passionate breed of New Yorker — those who come here by choice, fall in love with the town and do their damnedest to make it better.

Byford mingled with straphangers and bus riders as no predecessor ever did. Subway “management” notoriously means buck-passing responsibility — governor vs. mayor, management vs. union. Byford would have none of that. Following a bad service problem last summer, he said, “Regardless of the key players involved, the bottom line is we didn’t get people from A to B, and that’s not right.”

Byford stomped on the second Empire State rule as well: Never, under any circumstances, display competence as measured in tangible results. In two years, he improved on-time subway performance from 58 to 80 percent, kick-started upgrades to century-old signals and even managed to speed up some trains that had long moved more slowly than mice.

That was altogether too much good news for Cuomo, whose own “accomplishments” include spending $90 million of public dough on a Syracuse lightbulb factory that never was built and a $15 million “film hub” that made no films before the state sold it to a private company for $1.

Cuomo’s now in his third term thanks to negligible Republican opposition. He’s still the Imperial Andrew for now, but he might have gone too far with Byford.

Polls show widespread fury over the governor’s acquiescence in dropping bail requirements for all but the most violent criminals. Showing Andy the exit is Cuomo’s second huge political miscue in the space of a few months.

Byford, of course, couldn’t fix everything. The thousands of raging, incontinent and violent “homeless” — i.e., drug-addicted head cases turned loose by deinstitutionalization — couldn’t be reined in by slightly speedier trains or cheering words.

But Train Daddy’s concrete achievements gave us hope. They reminded us that the subways, the Big Apple’s lifeblood, are worth fighting for — even if Cuomo and his crowd would rather commute in limousines.