Larry Wilmore, center, and two of his contributors (Grace Parra and Jordan Carlos, left) talk to Sen. Bernie Sanders on “The Nightly Show.” (Bryan Bedder/Comedy Central)

Larry Wilmore sipped a glass of wine at the desk of his recently-canceled “Nightly Show” and reflected on his 18-month run on Comedy Central, which officially ends Thursday.

“We started our show thinking all the good bad race stuff was done already, but apparently we were wrong,” he told viewers Tuesday night. “And we’ve covered race from just about every angle you can think of.”

Wilmore threw to footage of controversial incidents he had covered on his late-night talk show, including a Texas police officer aggressively breaking up a pool party attended by black teenagers, and a Georgia principal who mocked people exiting a high school graduation ceremony early by saying, “Look who’s leaving: all the black people.”

For fans of “The Nightly Show,” Wilmore’s smart commentary on race will be sorely missed amid an ongoing debate around fatal police shootings and the racial tension in a presidential election marking the end of a historic presidency — the “Unblackening,” as the show dubbed it in a recurring segment.

In an interview with The Post, Wilmore said he was told last Thursday of the cancellation and that it came as “a shock.” “Even if we weren’t picked up for the next season, I thought we’d be on at least through the election,” he said.

In Jan. 2015, the veteran writer-producer and former “senior black correspondent” for “The Daily Show”took over the 11:30 time slot previously held by “The Colbert Report,” becoming late-night’s only black host before Trevor Noah inherited “The Daily Show” from Jon Stewart.

On Monday’s show — his first since the cancellation was announced — Wilmore made a pointed joke that highlighted the show’s unique perspective.

“My only regret is that we won’t be around to cover this truly insane election season,” Wilmore said. “On the plus side, our show going off the air has to only mean one thing: Racism is solved. We did it.”

The show’s frequent discussions of race often made headlines, but “The Nightly Show” also focused on gender, economic equality and other social issues. The show introduced a “Tampon Tuesday” segment to discuss the taxation of feminine products and related subjects. From the beginning, Wilmore said that he wanted his show to be a voice for “the underdog.”

Comedy Central's president says that Larry Wilmore's late-night show "hasn't resonated." Here's why else the show didn't make it. (Nicki DeMarco/The Washington Post)

The show’s diverse staff reflected those values. “The Nightly Show” made history by hiring Robin Thede as the first black woman to lead a late-night show’s writing staff. Earlier this year, Thede transitioned from head writer to writer-contributor, joining a pool of eight on-camera panelists that appeared with Wilmore and his guests on a rotating basis. Four are women of color. Only one of those contributors — showrunner Rory Albanese — is white.

In an interview, Thede described the writers’ room as “a really fun environment,” devoid of the competition that’s typical on other late-night shows.

“Everybody brought their own unique thing to the table,” Thede said. “Larry also really encouraged us to have clear points of view. Even if he didn’t agree with something — if you could convince him of it, he was really open to it.”

Albanese told The Post that the show struggled in its initial format, which involved hosting four different panelists each night. But it found stronger footing after paring down the number of guests and figuring out a comedy style — which he describes as “early Conan mixed with ‘The Daily Show’ ” — that worked.

“The struggle was getting to where we got, and I feel like had we gotten to where we are now faster, people probably would have caught on,” Albanese said.

The show had to compete against Jimmy Fallon, Jinmy Kimmel and predecessor Stephen Colbert in the 11:30 time slot. Plus his former “Daily Show” colleagues Samantha Bee and John Oliver each have formidable weekly political talk shows, while NBC’s “Late Night” host Seth Meyers has also emerged as a strong voice in political comedy.

“As far as political commentary goes, there are a lot of choices,” Albanese said. “Everyone’s doing really great stuff.”

But the biggest challenge may have been Stewart’s departure from“The Daily Show” — Wilmore’s lead-in — last August. “When Jon went off the air, we hadn’t really found our show yet,” Albanese said. (Stewart also happens to be an executive producer of “The Nightly Show.”)

“The Daily Show” has declined in ratings since Noah took over for Stewart. And in July 2015, right before Stewart’s departure, “The Nightly Show” averaged just over 1 million viewers, according to Nielsen. This July, the average was 770,000.

But “The Daily Show” has seen success among millennial viewers — Noah’s show is second in late-night viewership among the coveted 18-to-34 demographic. Recently, Comedy Central touted “The Daily Show’s” success on digital and mobile platforms. Comedy Central president Kent Alterman told the New York Times that “The Nightly Show” hadn’t seen similar growth. “We just haven’t seen it on any level from the general conversation to ratings to any sort of traction on social media platforms,” Alterman said.

Despite ratings, Wilmore told The Post that he is “very proud” of the show he and his staff made. “We definitely introduced voices that people didn’t know about and didn’t always see,” Wilmore said. “We weren’t a show that was trying to book movie stars because we wanted people who brought a different perspective to late-night.”

Last year, as protests raged in Baltimore following the death of Freddie Gray, Wilmore met with a group of local gang leaders who had declared a truce in hopes of curbing escalating violence. Wilmore listened as the men described a city in turmoil. The segment, which the show re-aired Monday night, was offbeat and earnest — the kind of segment you’d only see on “The Nightly Show.”

Like his peers, Wilmore faced the daunting task of talking about tragic events from a comedic perspective. “Our show was at its best when the news was at its worst,” he told viewers Monday.

“I always said, ‘We try to find humanity in a story and then mine jokes out of that, but it’s very difficult,” Wilmore told The Post. “But we made a promise to ourselves to try to cover the difficult stories and the things that maybe we’re afraid to talk about.”

Thede cites the show’s coverage following the Charleston church shooting as one of its best episodes.

“We had an incredible show — not capitalizing on that tragedy, but being able to bring in our audience and empathize with them and make them feel that we understood, that we felt the way they felt and that we were outraged as well,” Thede said.

“That touches a nerve with people,” she added. “Our audience was small, but it was mighty.”

Wilmore gave a shout-out to the show’s passionate fans at the top of Monday’s show. “People come up and they never say ‘Hey, nice show. They say, ‘Thank you,’ ” he told viewers. “It’s such a cool thing.”

Wilmore, who co-created the upcoming HBO comedy “Insecure” with Issa Rae, told The Post he will take some time after Thursday’s final broadcast to think about what he wants to do next. But he wants his fans to know that he hasn’t ruled out a return to late night.

“To be continued. We ain’t done yet,” Wilmore said. “We’ve only kept it 99. We’ve got a ways to go before we can keep it 100.”