President Donald Trump defended his embattled personal foundation after it agreed to shut down amid allegations the nonprofit misused funds on political and business purposes.

The Donald J. Trump Foundation “has done great work and given away lots of money, both mine and others, to great charities over the years,” Trump said Wednesday in a tweet.

New York Attorney General Barbara Underwood sued the charity in June, alleging the foundation functioned as “little more than a checkbook to serve Mr. Trump’s business and political interests.”

Trump said New York Governor Andrew Cuomo and other Democrats have “slammed” the charity with the lawsuit. He blasted former New York Attorney General Eric Schneiderman, who initiated the investigation, as a “sleazebag.”

“I wanted to close the Foundation so as not to be in conflict with politics,” Trump said in a tweet.

Amy Spitalnick, a spokeswoman for Underwood, said the attorney general filed the suit after an investigation “found a shocking pattern of flagrant and repeated illegality — including willful self-dealing to serve Mr. Trump and his business and political interests.”

Spitalnick pointed to a ruling by the judge handling the case last month rejecting Trump’s request to dismiss the lawsuit on a claim of political bias.

Underwood and the foundation agreed to dissolve the charity and give away its remaining $1.7 million, according to filings Tuesday in state court in Manhattan. Trump’s charity announced in 2016 that it would dissolve, before Underwood sued the foundation along with Trump and his three eldest children. The state blocked that plan until it could establish oversight of the closure.

The charity’s dissolution doesn’t end the pending lawsuit against the president and Ivanka, Eric and Donald Trump Jr., who could be temporarily barred from serving as directors of any New York nonprofit. And unless an appeals court blocks the attorney general, the process of uncovering evidence in the suit may allow the state’s lawyers to reach into the Trump family’s financial dealings, where some of the president’s critics believe there will be evidence of improprieties.

Get our Politics Newsletter. The headlines out of Washington never seem to slow. Subscribe to The D.C. Brief to make sense of what matters most. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Contact us at letters@time.com.