The picture that is emerging from Tuesday’s Rancho Tehama Reserve shooting rampage is that a mentally unstable man was bent on killing – and that only quick thinking by school officials and swift action by law enforcement prevented even more deaths.

Kevin Janson Neal, 43, was charged with assault and false imprisonment in late January in connection with an attack on two women. He was released on $160,000 bail and required to turn in any guns by a restraining order.

While Neal’s uncle said his weapons had been taken, Assistant Tehama County Sheriff Phil Johnston said Wednesday he did not know whether any firearms were turned in. Apparently it didn’t matter because Neal used two semiautomatic rifles he illegally assembled himself. He was also armed with two handguns that were not registered to him.

Authorities believe that Neal killed his wife, who was found shot to death hidden under the floor of their home, on Monday night. Neal called his mother in North Carolina that night and told her, “It’s all over now,” the Associated Press reported.

Digital Access for only $0.99

The shooting spree started early Tuesday. The first call for help came into the sheriff’s dispatch center at 7:54 a.m. One of the women he allegedly assaulted in January and another neighbor were the first victims, officials say. They say Neal stole a truck and fired randomly at buildings and passing vehicles and chased people to try to shoot them.

By 8:19 a.m., when officers had rammed his vehicle and shot and killed Neal, three more people were dead and at least eight wounded, including seven children.

As horrific as the carnage was, it could have been worse.

While much remains murky, it is clear that the immediate decision to lock down Rancho Tehama Elementary School saved many lives. It may have prevented a massacre on the scale of Sandy Hook Elementary in Connecticut, where 20 first-graders and six teachers and staffers were slaughtered in 2012.

The sheriff’s office says that school officials didn’t wait for the official notification, but locked the doors immediately after hearing gunshots. That blocked Neal, who crashed through the gates and fired through windows and walls. One student was shot and three others were hurt by flying glass or debris.

“It’s monumental that the school went on lockdown,” Johnston said. “I really, truly believe that we would have had a horrific bloodbath at that school.”

This should be a lesson for every principal and superintendent in California to act quickly on lockdown orders, not be afraid to make the call on the spot and to take active shooter drills seriously.

As after every mass shooting, we will be searching for other lessons. There will be questions – that may never be fully answered – of whether something could have been done to prevent it, whether warning signs were missed.

Family members said Neal had struggled with mental illness and a violent temper and was feuding with neighbors whom he suspected of making methamphetamine.

Johnston said deputies had been called to Neal’s home several times for suspected domestic violence and after neighbors’ complaints of shots being fired, but said Neal would not come to the door and armed neighbors didn’t cooperate. At least twice, Johnston said, deputies watched the home to see if Neal would come out.

What also isn’t known yet is whether Neal was on a state list of people prohibited from having guns, which could have led to agents going to his home and seizing them. Officials say under state law they can’t disclose individuals on the list.

After Sandy Hook, Gov. Jerry Brown and the Legislature added $24 million to enforce the Armed and Prohibited Person System. Additional agents were hired to reduce the backlog of registered gun owners who are banned from possessing them because they are later convicted of crimes, detained for mental illness or subjected to a restraining order.

At the start of 2014, the backlog stood at 21,249 individuals. By the end of 2016, that number had been cut to 10,634. The state Department of Justice reports that last year, it conducted 9,183 investigations, resulting in 511 arrests and the seizure of 3,954 firearms.

California has some of America’s strictest gun control laws. But if they’re not enforced aggressively and smartly, they won’t be as effective as they should. And even then – as the Tehama rampage may eventually show – there may be very little to stop a madman.