An aerial view of the aftermath of the 2013 Lac-Megantic train derailment. Reuters

A group of oil companies have come to an agreement with victims of the 2013 oil train derailment in Lac-Megantic, Quebec, Canada, when a train carrying 7.7 million liters of crude oil derailed, resulting in a massive spill and explosion that killed 47 people. The companies agreed to a $345 million settlement through a bankruptcy court procedure, the Wall Street Journal reports.

Several companies agreed to pitch in on the $345 million, though it is difficult to determine how much each will contribute. Royal Dutch Shell, Marathon Oil Corp., Conoco Phillips and Irving Oil were all named as contributing. The companies were all shipping oil from North Dakota oil fields.

A spokesperson for the town, which has about 6,000 people, said they hope the settlement would help the town “turn the page” on the tragedy, according to the Wall Street Journal.

The settlement was reached in bankruptcy court to avoid costly and lengthy court dramas that can result from accidents like this. The agreement, if approved by the court, would shield the companies in the future from any wrongful death or negligence lawsuits. It also makes it possible for the two sides to come to one, distilled agreement.

The accident occurred on July 5, 2013, while the train, which had 63 cars, was parked for the night, as is protocol. The conductor, when leaving the train, tested the hand brakes, but he failed to turn off the air brakes beforehand, meaning that there was no way to be sure that the hand brakes were adequate to keep the train from moving forward down the incline it was on. A fire later erupted in the car, and responding firefighters turned off the main switchboard, which meant that the airbrakes were no longer being replenished.

The train eventually moved forward as the airbrakes let up. It reached a maximum speed of 65 miles per hour in that time, and derailed in the middle of the town just after 1 a.m.

There have been several fiery train derailments in the time since, though no deaths have so far resulted. A few precautions were implemented following the 2013 tragedy, like trains being required to slow down and companies implementing stronger cars that can handle derailments better. Still, efforts on the part of U.S. officials to get the oil companies to strip volatile and dangerous gases and substance from the crude before shipment have been met with some resistance.