THOUSAND OAKS, Calif. — Authorities are trying to piece together why a Marine combat veteran opened fire during a College Night at a crowded country dance bar in Southern California, killing 12 and sending terrified patrons jumping through windows to escape.

Among the dead is a sheriff's sergeant who rushed to the scene of the late-night shooting Wednesday.

The gunman, David Long, 28, wore a hood, bandana and black clothing as he indiscriminately fired into the crowd. Ventura County Sheriff Geoff Dean said Long, who lived in the town of Newbury Park, killed himself as police closed in.

Long was a former machine gunner and Afghanistan war veteran who was interviewed by police at his home last spring after an episode of agitated behavior that authorities were told might be post-traumatic stress disorder.

The violence erupted at the Borderline Bar and Grill, a country western dance bar in Thousand Oaks, about 40 miles west of Los Angeles. Hundreds of people fled in terror, including some who used bar stools to break windows and escape.

"It’s a horrific scene in there,” said Dean, who choked up at one point while speaking to reporters in the bar's parking lot. “There’s blood everywhere.”

The sheriff said police have had "several contacts" with Long in recent years. Most notably, police said, he was "angry and acting a little irrationally" when a mental health crisis team was called to his home earlier this year to investigate a disturbance. The team concluded Long did not need to be taken into custody, he said.

In addition, Long was listed as the victim in a bar skirmish three years ago, Dean said.

At a late-afternoon news conference Thursday, Paul Delacourt, assistant director of the FBI's Los Angeles field office, said the crime scene, the gunman’s home and car were being processed for evidence. But he said it was too early to determine a motive for the shootings.

"We're hoping to paint a picture of the state of mind of the suspect," Delacourt said.

Democratic Gov.-elect Gavin Newsom, in his first public appearance since winning office on Tuesday, lamented the violence that has come again to California.

“It’s a gun culture,” he said. “You can’t go to a bar or nightclub? You can’t go to church or synagogue? It’s insane is the only way to describe it. The normalization, that’s the only way I can describe it. It’s become normalized.”

A Marine corporal, Long served for five years – from 2008 to 2013 – including a seven-month tour in Afghanistan, according to Marine Corps records. Long earned several awards, including a Combat Action Ribbon and a Marine Corps Good Conduct Medal.

Police say he was armed with a legally purchased Glock 21 .45-caliber handgun designed to hold 10 rounds plus one in the chamber. But the sheriff said the gun had an extended magazine that is illegal in California.

After spraying bullets for almost three minutes, the gunman entered an office near the front of the bar, where he was found dead of an apparent self-inflicted gunshot wound.

"It appears he walked up to the scene, shot the security guard who was standing outside, then stepped inside," Dean said. "It appears that he turned to the right and shot several of the other security guards and employees and began opening fire inside the nightclub."

Pepperdine University said on Twitter that "multiple" students from the college were at the scene during the attack.

Officials at California Lutheran University in Thousand Oaks canceled classes for the day, university spokeswoman Karin Grennan said. Officials said they didn’t know whether any of the students were among the victims but nonetheless opened the campus chapel and deployed school counselors.

Eighteen people made their own way to local hospitals, and two were taken by ambulance, according to the Ventura County Sheriff's Office.

Sheriff’s Sgt. Ron Helus, who was shot after he entered the building, died at a hospital early Thursday.

Helus and a passing highway patrolman were responding to several 911 calls when they arrived at the bar around 11:20 p.m., the sheriff said. They heard gunfire and went inside.

Helus was immediately struck by multiple gunshots, Dean said. The highway patrolman cleared the perimeter and pulled Helus out and waited as a SWAT team and scores more officers arrived.

The sheriff said there were “multiple other victims” with different levels of injury.

The bar, which includes a large dance hall with a stage and a pool room along with several smaller areas for eating and drinking, is a popular hangout for students from nearby California Lutheran University, particularly on College Night.

More:What we know about Thousand Oaks gunman Ian David Long, a Marine veteran

More:Some Thousand Oaks victims survived mass shooting in Las Vegas, reports say

More:'He died a hero': Ventura County Sheriff Sgt. Ron Helus among those killed in bar shooting

More:Extended magazine used in California shooting can't be bought legally there

It’s also close to several other universities, including California State University Channel Islands in Camarillo, Pepperdine University in Malibu and Moorpark College in Moorpark.

The mood on campus is "definitely somber," said a 22-year-old junior at Pepperdine who identified herself only as Anne. "I think one girl (from Pepperdine) is still missing. We're praying."

She says support on campus has been offered on several levels. "There's a prayer group that's going on. The counseling center's open. There's tons of things that we have access to."

Jason Coffman received confirmation that his son Cody, 22, who was about to join the Army, was dead. Coffman broke down as he told reporters how his last words to his son were not to drink and drive and that he loved him.

“Oh, Cody, I love you, son,” Coffman sobbed.

It was the deadliest mass shooting in the United States since 17 classmates and teachers were gunned down at a school in Parkland, Florida, nine months ago. It also came less than two weeks after a gunman killed 11 people at a synagogue in Pittsburgh.

Matt Wennerstrom, 20, said the attacker first opened fire on employees working the front desk.

"I grabbed as many people as I could and pulled them down underneath the pool table we were close to until he ran out of bullets for that magazine and had to reload," he said.

Wennerstrom, a regular customer, said he and other patrons used bar stools to break open a window to help people escape. "We were shuttling as many people out as we could," he said.

President Donald Trump ordered flags to be flown at half-staff until sunset Saturday at the White House and on all public buildings, military posts, naval stations and aboard all U.S. naval vessels. He also directed the flag to be flown at half-staff at all U.S. embassies and military bases and naval stations abroad.

A witness, John Hedge, said he saw the suspect tossing smoke bombs into the front of the restaurant, KABC-TV reports.

"The gunman was throwing smoke grenades all over the place. I saw him point to the back of the cash register ... and he just kept firing. I ran out the front door," he said.

Taylor Von Molt, 21, who was line dancing in the bar when the shooting broke out, told CNN the burly gunman was wearing sunglasses and his face was partially covered by a bandana.

She said she first heard what sounded like a balloon popping until she realized it was gunshots. Von Molt said she fell down while rushing toward the exits and was slightly injured attempting to get up.

Officers indicated that about 30 shots had been fired and that patrons fled into the surrounding neighborhood. Shots were still being fired when officers arrived on the scene.

The Borderline Bar and Grill describes itself on its website as the county's "Largest Country Dance Hall & Live Music Venue," with 2,500 square feet of open dance floor.

On Thursday, townspeople, including a group of sophomores from La Reina high school, turned out for a procession for the slain officer. Paris Milazzo, 15, cried and hugged her friends as the sheriffs' vehicles drove past.

"Thousand Oaks is one of the safest cities in the country, and to think it still happens here," said Michele De Groote, 15, holding back tears. "You don't think that it's going to be your city, your home until you wake up that morning and your city is added to that list."

Contributing: Ventura County Star staff; Andrea Mandell and Jane Onyanga-Omara, USA TODAY; the Associated Press