Like a good legal thriller, CBS’ “The Good Wife” surprised fans right down to its closing moments as Alicia Florrick’s emotional roller-coaster ride of the past seven seasons came to an unexpected end.

SPOILER ALERT: Stop reading unless you have seen the May 8 finale of “The Good Wife.”

There were few neat and tidy endings in the series finale — appropriately titled “End”  — written by series creators Robert and Michelle King.  Julianna Margulies’ titular character spends the episode wrestling with the intellectual instincts that get in the way of what her heart wants. Thoughout the hour she gets counsel from a surprising source: Will Gardner, the love-of-her-life fellow lawyer who died a violent death back at the end of season five.

Josh Charles did indeed make a memorable return to the show to give Alicia a kick in the pants, although it’s not clear whether she takes all of his romantic advice.

The ending leaves Alicia at a crossroads, professionally and personally. We learn that the ever-scheming Eli Gold has plans to “invest” in her as a political candidate — just as soon as the Florrick divorce papers are dry – in an effort to hang on to what’s left of her husband Peter’s base of donors and voters. Crassly, Eli starts plotting this shift with Peter even before he broaches the subject with Alicia — although Alicia is cunning enough to have perhaps anticipated this move already. “It’s the smart move,” Eli tells Peter. This is hitting Peter where it really hurts — the loss of his political career. Alicia tells him the same thing at another point in the episode when Peter weighs whether to take the generous, jail-free plea deal that Alicia has wrangled.

“My career will be over,” Peter sighs. “I think it’s over anyway, isn’t it?” Alicia replies.

But is Alicia really equipped to go for it in politics? She’s knee-deep in a personal mess after making an enemy of Diane Lockhart as part of her zealousness to defend her client, Peter. At one point when Alicia seems floored by the mounting evidence of her husband’s guilt in the obstruction of justice issue, it’s Diane who reminds her: “He’s still your client. That’s why you care.”

In the larger context sketched by Eli and Alicia’s actions, maybe she is seduced by power and eager to climb the ladder now that her soon-to-be-ex husband is neutered. Alicia stands with Peter as he resigns his governorship — a move that Peter describes as “one last favor.”

The final sequence that features Diane slapping Alicia in the hallway — a great callback to the series premiere when Alicia delivers the smack to her philandering husband — leaves Alicia’s next move ambiguous. Surely, she’s done with Peter. That is telegraphed when he reaches out for her hand after his resignation speech but she’s already down the hallway, chasing what she believes is the shadow of Jason Crouse, the living object of her affections.

But he’s not actually there, as she finds out. Diane’s hand, however, is, and she lets Alicia have it for conspiring with Lucca — against Diane’s orders — to tear down the credibility of Diane’s husband Kurt while he testifies on ballistic matters during Peter’s trial. Through a convoluted series of events that also involves Cary (who appears to be on track to become a law professor) doing one last honorable thing in connection with the Florricks and that pesky murder case (even though it doesn’t help them), Kurt winds up being confronted on the stand that he has had an affair with Holly Westfall, played by Megan Hilty, who bought his firearms and ballistics firm.

The way Alicia straightens her suit, dabs away the tears from her eyes and walks stoically back down the hallway seems to suggest that she’s ready to become a political animal, despite her first struggle with elected office. Or was the slap from Diane the last bit of shakeup she needed to pursue a romance with Jason? This point will surely be debated by fans in the court of recaps — and the appellate courts of comment sections.

Alicia’s visions of Will Gardner are well played by Margulies and Charles. In the hands of lesser actors they might have seemed over the top. But the scenes are played as if they could have been from seasons one or two, without a shred of hallucinogenic quality other than the jolt of Alicia shaking herself out of the vision.

Will delivers some great lines with characteristic blunt-ness that are obviously meant to help viewers process where Alicia stands. Her “I’ll always love you” bit with Will is a fantasy of her own construct that is comfortable for her, especially now that he’s gone-gone. Like Lucca, Will urges Alicia not to blow it with the tattooed splendor of Jason, played by Jeffrey Dean Morgan.

“It was romantic because it didn’t happen,” Will tells Alicia of their ups and downs. “So now you got a little bit of both: life, us together and now romance.”

If we’re to believe that Alicia’s visions of Will are her subconscious trying to find a way to get her to act decisively, then it stands to reason that Alicia will use all of her formidable skills to chase down Jason or another man who can make her happy. “You have so little self-awareness,” Will tells her, needling Alicia when she tries to offer excuses why Jason’s not the one. “Do you want to live here alone? Go to him, it’s not too late,” Will insists.

But before she hears all this from Will, Alicia pulls a move right out of a paperback romance novel by whispering in Jason’s ear: “Wait for me,” presumably while she sorts out Peter’s fate. That’s gotta be a turn off for a guy who doesn’t know if he wants to commit at all (although we suspect he’s just waiting for a strong signal from Alicia).

Judge Cuesta, played by David Paymer, presiding over Peter’s trial, adds to the many voices trying to steer Alicia in a new direction with his quotation of Orwell: “To see what is in front of your nose is a constant struggle.” Lucca gently scolds her early in the episode: “You tend to confuse responsibility and love.”

In the first half of the episode, there’s some classic “Good Wife”-meets-“Perry Mason” moments as  Lucca, Diane and Alicia hustle to play both ends against the middle. They’re trying to get Peter the best plea deal they can score while leaving options open against the jury acquitting Peter, which seems likely when the jurors request information that pokes into the specifics of the murder case rather than Peter’s actions as state attorney general.

The real-life legal eagle David Boies makes a fun guest appearance as himself — an A-list expert witness designed to impress the judge.

The Kings made good use of Regina Spektor’s 2006 two-hanky love song “Better” in the soundtrack to Alicia’s swan song. The lyrics would seem to suggest that Alicia may still be searching for her heart’s desire.

If I kiss you where it’s sore
If I kiss you where it’s sore
Will you feel better, better, better
Will you feel anything at all
Will you feel better, better, better
Will you feel anything at all