Grayson Allen did not have the greatest outing against Kansas. (Streeter Lecka/Getty Images)

Grayson Allen’s Duke career ended Sunday, but not before he came agonizingly close to making a shot that would have given his team a berth in the Final Four. It also didn’t end before the senior guard gave his legions of haters one last chance to hate on him, and to revel in his failures against Kansas.

With the clock ticking down on regulation in a game tied at 72 apiece, Allen kept the ball and tried to maneuver around Jayhawks defenders in search of an open shot. However, he wound up taking an off-balance 14-footer that hit the rim twice before rolling off as time expired.

The game went to overtime, where Allen was again unable to play the hero, as top-seeded Kansas held off the No. 2 Blue Devils, 85-81, to win the Midwest region. Allen actually made his final shot, a three-pointer, but it was too little, too late, after he had missed his two previous shots in the extra session, as well as committing two personal fouls and a turnover.

All of that was catnip to the many college basketball fans who have come to consider Allen the sport’s foremost villain, the latest in a long line of white Blue Devils, including the likes of Christian Laettner and J.J. Redick, whom supporters of other teams have loved to hate. Even though Allen had a quieter senior season, in terms of causing outrage, than a junior campaign marked by incidents of tripping opponents, he was still a target for derision every time he played away from the friendly confines of Durham, N.C., including at the NCAA tournament.

“I think I surprise people when I say that, but I don’t [enjoy playing the villain],” Allen told the New York Post before the Kansas game. “You learn to own it, I’ve learned to accept it. I don’t feed off of the boos, I don’t feed off anything like that. … No one likes to get booed, no one likes to get cussed out, no one likes to get yelled at by 20,000 fans when you go places.”

It wasn’t just fans at tournament arenas, of course, who let their negative feelings about Allen be known, but also plenty of people online. As his Blue Devils lost to the Jayhawks, ending his college career, the Internet filled with schadenfreude, as well as the obligatory Ted Cruz references.

It wasn’t just key late-game shots that Allen missed — he had a poor shooting night overall, making just 3 of his 13 field goal attempts, including 2 of 9 from beyond the arc. Allen, who played an important role as the 2015 Blue Devils won the NCAA tournament, did add four assists and four steals to his 12 points Sunday, but in the wake of Duke’s defeat, he was left to look back on his time with the school rather than forward to a chance at a second national title.

“There’s a lot of joy, a lot of happiness, when I look back, a lot of growth,” Allen said at his locker. He added with a chuckle, “From an outside perspective, it might look like I went through hell for a little bit, and it kind of felt like it during the middle, but I wouldn’t trade it for anything.”

Allen’s detractors might not trade away their experiences of hating on him, either, because every good story needs a villain, right? Or at least, every good Duke squad, it seems, needs a player to become the focus of opposing fans’ ire, and whether he liked it or not, Allen perfectly fit the bill.

His resemblance to Cruz, an unpopular national figure, helped establish Allen as a target of mockery as soon as he began playing for the Blue Devils, and he did not help himself by tripping players — a tactic many thought he returned to with a hip-check on North Carolina’s Garrison Brooks earlier this month in the ACC tournament. However, Allen did all college basketball fans a favor by being a noteworthy presence, for good or ill, for all four seasons.

If he manages to stick around in the NBA, Allen can likely expect to see much of the negative energy fade away over time, as it did for Redick and, to a lesser degree, Laettner. In the meantime, though, his haters are not exactly unhappy about how Allen’s Duke career came to an end.

Read more from The Post:

Kansas beats Duke and its Elite Eight demons with an overtime classic

Known as pretty, Villanova is gritty in knocking out Texas Tech to reach Final Four

CBS’s Dana Jacobson asks a question Florida State’s Leonard Hamilton won’t answer

Doug Williams on Su’a Cravens: ‘Right now, he’s a Redskin,’ but ‘everybody is tradable’