(CNN)The following contains spoilers about "Homeland's" sixth-season finale.
"Homeland" might have got the gender of its fictional president wrong, but as usual, the sixth season of the Showtime series -- which concluded Sunday -- also got plenty right in weaving real-world threads into its storyline, while still delivering the taut attributes of a thriller.
More than most shows in the genre, "Homeland" operates in gray areas, avoiding facile solutions or easy answers. Where most dramas preoccupied with terrorism gravitate toward the good and bad, this one often deals in murky choices between the lesser of two evils.
That was abundantly true of the season finale, which saw the end of what amounted to a coup attempt against the president-elect (Elizabeth Marvel) and a thwarted assassination plot. What followed, however, also validated concerns that she would overreach as president, flashing forward to the sweeping purge undertaken in response to those events.
The payoff left the program's heroine, Carrie Mathison (Claire Danes), who ostensibly had the president's ear, at a professional and personal crossroads. With the series already renewed for two more seasons, it also sets up several tantalizing prospects as the show presumably arcs toward its finish.
The finale's narrative twists capped a season dominated by a clandestine war between the incoming administration and the intelligence community. As a bonus, it also featured an elaborate "fake news" operation conducted with the latter's blessing, run by a bombastic talk personality clearly intended to resemble Infowars' Alex Jones.
Under Dar Adal (F. Murray Abraham, in his most expansive work for the show to date), the CIA fretted about the new Commander in Chief gutting its operations. Those forces went so far as to frame a Muslim-American youth with a provocative online footprint in a terrorist attack, in what might be a construed as a reaction to legitimate criticism of "Homeland's" past depictions of Muslims as terrorists.
All that built toward Sunday's finale, in which the orchestrated attempt on the president's life resulted in the sacrifice of Carrie's longtime associate, Peter Quinn (Rupert Friend), in order to save her.
"Ultimately, I lost control of what I set in motion," Dar Adal told CIA colleague Saul Berenson (Mandy Patinkin), a line that neatly described the frequent "Homeland" theme of unintended consequences.
The producers have discussed that they were roughly halfway through writing the season when Donald Trump was elected president, suddenly casting their efforts into a different light. As executive producer Alex Gansa noted, "things have gotten even more contentious between Trump and the intelligence community, which is what our whole season was about crazily enough."
Alas, not everything else about the sixth season worked equally well. Quinn's emotional fate came after an extended subplot dealing with the stroke he suffered in staving off a terror threat, and while a sympathetic figure, that felt more like a distraction from the main themes than an addition to it.
Quinn has always provided a window into Carrie's conflicted soul, but much of the drama surrounding them simply felt strained. That included Carrie potentially losing custody of her child, a rather manipulative way to showcase the difficulty of work-life balance when the gig is in counter-terrorism.
Those missteps, however, played like relatively minor flaws in a season that proved compulsively watchable -- one that has set events in motion that should whet appetites for what's to come more than any recent "Homeland" edition.