SAN DIEGO (AP) — Conan O’Brien has made peace with a man who heckled him not from the crowd but the courts.

O’Brien and several co-defendants, including his writing staff, agreed Thursday to settle a 2015 lawsuit with California writer Robert Kaseberg, who alleged the talk-show host stole five jokes from his Twitter feed and blog for O’Brien’s monologues on his TBS show, “Conan.”

Attorneys for both sides filed documents in San Diego federal court announcing a deal had been reached about three weeks before a trial that would have seen O’Brien, his sidekick Andy Richter and other famous names called to the stand. Terms of the deal were not disclosed.

The joke-theft case was rare from the start, and O’Brien also gave it an unusual ending, explaining why he settled at length in a column in Variety rather than opting for the confidentiality common in Hollywood lawsuits.

O’Brien insists that he and his staff had never heard of Kaseberg, his blog or his Twitter account before the lawsuit, and did not steal any jokes. But he did not want “a farcical and expensive jury trial in federal court over five jokes that don’t even make sense anymore.”

“Short of murder, stealing material is the worst thing any comic can be accused of,” O’Brien writes. “Had I, for one second, thought that any of my writers took material from someone else I would have fired that writer immediately, personally apologized, and made financial reparations.”

Kaseberg released a statement saying he was happy with the friendly resolution.

“As a professional comedy writer, all I want to do is make people laugh and stand up for the things I believe in,” Kaseberg said. “I am proud my case helped shed light on an issue facing all comedy writers and am happy to have been part of contributing legal precedent on the issue of protection afforded to jokes.”

One of Kaseberg’s jokes that closely resembled O’Brien’s was about 2015 Super Bowl MVP Tom Brady giving the truck that goes with the title to Seahawks Coach Pete Carroll, whose coaching decisions many believe are the biggest reason Brady’s New England Patriots won.

“Trust me, Pete Carroll gags were hilarious back in 2015,” O’Brien writes.

O’Brien said the similarity of this and the other lines in the lawsuit is simply the result of the same comedians landing on the same newsy joke, a phenomenon that has exploded with social media.

“At the same time,” O’Brien writes, “that joke was being written by literally 34 other people on Twitter, and one of those people decided he had been robbed.”

O’Brien writes that he most wants to stand up for the integrity of his “remarkably hard-working and decent” team of writers.

“As I wrote several years ago,” O’Brien concludes, ” ‘No legacy is so rich as honesty.’ Of course, William Shakespeare is now claiming he tweeted that in 1603.”

But, O’Brien writes, Shakespeare “can talk to my lawyers.”