Disgraced financier Bernie Madoff, whose decades-long fraud swindled thousands of investors out of billions of dollars, died in federal prison Wednesday, the Federal Bureau of Prisons confirmed. He was 82.

Madoff had served a dozen years of what was a 150-year prison sentence for defrauding famous and wealthy investors of approximately $17 billion in what is believed to be the largest Ponzi scheme in history.

His scheme also bankrupted thousands of average Americans, wiping out their entire retirement savings.

The court-appointed trustee tasked with liquidating all of Madoff’s assets said in 2019 he had returned over $14 billion to investors, which comprised over 80 percent of what was lost in the scheme.

The collapse of Madoff’s decades-long fraud deeply affected his family. Madoff’s brother, Peter, was the chief compliance officer for Madoff Investment Securities. He was sentenced to 10 years in prison as part of the scheme.

Both of Bernie Madoff’s sons also worked for Madoff Investment Securities but said they knew nothing of the fraud until their father told them about it in 2008. Mark committed suicide in 2010; Andrew died of cancer in 2014.

A total of 15 employees at Bernie Madoff’s firm were either convicted for their part in the fraud or cooperated with investigators to reduce or eliminate their sentences.

JPMorgan Chase, which had handled Madoff’s bank accounts for more than two decades, paid a $1.7 billion fine in 2014 to the Department of Justice to settle allegations the bank knew about Madoff’s fraud but failed to alert authorities. The money was returned to the victims of the scheme. At the time, it was the largest-ever fine paid for violations of the Bank Secrecy Act.

The scheme might never have lasted as long as it did, or defrauded so many of so much, if the Securities and Exchange Commission had listened to whistleblower Harry Markopolos. Markopolos discovered the fraud in 2000 and submitted his evidence to the SEC’s Boston office. He submitted more evidence to SEC offices in 2005, 2007, and 2008, according to a 2009 interview he gave Fraud Magazine.

“The important thing you have to know about Madoff is that he is a brilliant con artist who knew how to prey on human nature like few others,” Markopolos said. “Investors who asked too many questions were told not to invest. If you asked detailed due diligence questions and wanted full transparency and an independent third-party bank to custody assets and clear trades, then Madoff would tell you, ‘It’s a take-it-or-leave-it black box strategy. I invented this strategy, and if I let third parties see what I’m doing, then they will duplicate the strategy and kill my returns by competing away the market inefficiencies I’m exploiting.’ ”

Near the end of his life, Madoff made two attempts to shorten his prison term.

In 2019, Madoff asked President Donald Trump to commute his sentence. Trump never acted on the request.

Last year, Madoff petitioned the Bureau of Prisons for a compassionate early release from his sentence because he was suffering from terminal kidney disease that would likely kill him in 18 months. His request was denied.