A tiny Northern California elementary school would have turned into a “bloodbath” if not for quick action by school workers who rushed small children inside and locked down the building, thwarting a gunman on a deadly mission, authorities said.

Kevin Janson Neal repeatedly shot into Rancho Tehama Elementary School while trying to get inside. He eventually got frustrated and left.

“There is no doubt that he did not want to give up,” Tehama County Assistant Sheriff Phil Johnston said Wednesday. “I really, truly believe we would have had a horrific bloodbath at that school if that school hadn’t taken the action that it did.”

The school has about 100 children in kindergarten through fifth grade and four certified teachers, according to its website.

Some students had finished breakfast while others were being dropped off when Neal started firing Tuesday morning. Coy Ferreira told Redding television station KRCR that he was dropping off his daughter for kindergarten when gunfire erupted and a secretary ran out and yelled for the kids to race inside.

Ferreira said he ended up in a classroom with 14 students cowering under desks while shots rang out. Some bullets hit the windows and a boy was shot in the chest and foot, he said. The child is expected to survive.

Corning Union Elementary School District Superintendent Richard Fitzpatrick said he was alerted to the shooting by a brave secretary hiding under a desk as her fingers typed overhead.

Neal fatally shot five people, including his wife, before authorities killed him in Rancho Tehama Reserve, a rural community about 130 miles north of Sacramento.