U.S. President Barack Obama tapes an appearance on the "Late Show with David Letterman" at the Ed Sullivan Theater in New York on May 4, 2015. Letterman's last show is Wednesday. Reuters

When David Letterman signs off for the last time Wednesday night, he'll be going out on top. The "Late Show" host has earned big money in the nearly 35 years he's spent on TV. Letterman's net worth is estimated at $400 million, according to TheRichest.com, and he's invested in several companies and properties sure to keep him comfortable in retirement.

Letterman, 68, has been called the richest late-night show host, with a peak salary of $40 million and recent earnings of $20 million a year, Yahoo reported. His "Late Show" nabbed about $271 million in advertising revenue in 2009, but that's also fallen -- revenue last year was $114.5 million.

Worldwide Pants

Even though Letterman is leaving viewers' screens, he's not completely leaving the entertainment business. His production company, Worldwide Pants Inc., owns not only his "Late Show" material but also other series. The biggest is "Everybody Loves Raymond," which Worldwide Pants shares with CBS and HBO. In 2005, TBS bought the rerun rights for the show for $650,000 an episode through 2016, and Worldwide Pants is "is still reaping millions" from "Raymond," Yahoo reported.

Worldwide Pants was developing new shows, too. When Letterman announced his departure in spring 2014, the company was working on a Nickelodeon game show, as well as a Fox comedy starring Harry Connick Jr., the Hollywood Reporter reported.

Other Assets

Letterman also co-owns Rahal Letterman Lanigan Racing, an auto team based in Hilliard, Ohio, and Brownsburg, Indiana. Rahal Letterman Lanigan has 30 victories and three series championships, according to its website, and is sponsored by companies such as Steak 'n Shake and coupon site Valpak. It employs eight drivers. Two are due to race this weekend at the Indianapolis 500.

As far as properties, Letterman owns a $10 million, 108-acre estate in Westchester County, New York. In 1999, he bought the 2,700-acre Deep Creek Ranch near Choteau, Montana, where he has a 3,276-square-foot home with three bedrooms and three bathrooms. He has houses in Martha's Vineyard, Massachussetts, and St. Barts Island, as well.

What's Next

It's unclear whether the "Late Show" will generate much revenue if it goes to reruns, former RCA executive Seth Willenson told Bloomberg. Rereleasing archive footage could be Letterman's best bet for profiting from old content.

Worldwide Pants CEO Rob Burnett said "Stupid Pet Tricks" clips and "Top 10 Lists" could gain traction online. “There’s a lot of talk about the library, which is extremely valuable if handled correctly,” he added. “In today’s world, there are a lot of ways to monetize something with that volume and quality.”

Going forward, Burnett told Bloomberg he's not sure what will happen with the company. Letterman has said he wants to dedicate most of his post-"Late Show" free time to hanging out with his 11-year-old son, Harry. "I'm pretty sure that once it's finished there will be a time of introspection," he told the Tampa Bay Times. "Then I think I will relax into what would be kind of a normal life."