BISMARCK, N.D. (AP) — The last bit of settlement money from a class-action lawsuit over a disastrous train derailment in Minot a decade ago will go to charity.

Canadian Pacific Railway about five years ago agreed to pay $7 million to settle claims stemming from the January 2002 derailment that sent a cloud of anhydrous ammonia over North Dakota's fourth-largest city as most residents slept. The toxic farm chemical killed one man and sent hundreds more seeking medical help for eye and breathing problems.

Just short of $3 million of the settlement went to the plaintiffs' attorneys, and about $4 million was doled out to about 3,200 Minot residents — an average of about $1,250 per person, according to Analytics Inc., a Minnesota consulting firm that administered the settlement. That left about $7,100. U.S. District Judge Daniel Hovland this week approved a motion by the plaintiffs to give the money to the Northern Lights Chapter of Habitat for Humanity, a nonprofit organization that helps low-income people build homes.

"We selected Habitat for Humanity based on the work they do to create affordable housing, create a safer community," said Gordon Rudd Jr., a Minneapolis attorney who helped represent the plaintiffs. "It's just a well-known organization that does good work."

Chapter officials did not respond to telephone and email messages left Wednesday and Thursday seeking comment. The national Habitat for Humanity office declined to speak on the chapter's behalf.

The National Transportation Safety Board ruled that inadequate track maintenance and inspections were to blame for the Jan. 18, 2002, derailment on Minot's west edge, a finding that the railroad disputed. It resulted in years of legal wrangling and prompted Congress in 2007 to change a law that prevented people from collecting in personal injury lawsuits brought against railroads. The change was made retroactive to the date of the Minot disaster. Canadian Pacific challenged the constitutionality of the new federal law, but the U.S. Supreme Court in 2009 declined to get involved in the case.

Canadian Pacific also did not admit any wrongdoing in the class-action settlement, which resolved the majority of claims against the railroad. A few hundred people opted to pursue their own claims. The final known lawsuit stemming from the derailment and chemical spill was settled in 2010.

"I believe this is finally the end of a real disaster," Mike Miller, a Fargo attorney who also represented the plaintiffs, said of the charitable donation. "It's interesting, though — I still get a lot of calls from folks up in Minot (who say) 'you represented us.' It certainly hasn't left their mind."

Tom Lundeen, who became an unofficial spokesman for Minot residents affected by the derailment, said it remains fresh in his mind a decade later, even though his family has moved to a home in the countryside. At the time of the derailment, Lundeen and his family lived in a housing development near the site. The man who died in the toxic cloud lived just a few houses away. Lundeen suffered injuries he has not disclosed.

"It's something that will never go away," said Lundeen, who reached his own settlement with the railroad. "I'll remember it until the day I die. I don't dwell on it or think about it as much now that we're out of there ... I can sleep at night again."