Three women who devoted their lives to helping traumatized veterans were killed by a patient who had been kicked out of their treatment program, authorities and a relative of a victim said.

A day-long siege at the Pathway Home in Yountville in northern California ended on Friday evening with the discovery of four bodies, including the gunman. He was identified as Albert Wong, 36, a former US army rifleman who served a year in Afghanistan in 2011-2012.

Investigators were trying to determine when and why Wong killed two executives and a psychologist at the Pathway Home, a nonprofit post-traumatic stress disorder program at the Veterans Home of California-Yountville in the Napa Valley wine country region.

It was “far too early to say if they were chosen at random” because investigators had not yet determined a motive, California highway patrol assistant chief Chris Childs said.

Governor Jerry Brown ordered flags flown at half-staff at the capitol in memory of the victims. They were identified as Pathway Home executive director Christine Loeber, 48; clinical director Jennifer Golick, 42; and Jennifer Gonzales, 29, a clinical psychologist with the San Francisco Department of Veterans Affairs Healthcare System.

In a tweet on Saturday, President Donald Trump said: “We are deeply saddened by the tragic situation in Yountville and mourn the loss of three incredible women who cared for our veterans.”

In a statement, the Pathway Home said: “These brave women were accomplished professionals who dedicated their careers to serving our nation’s veterans, working closely with those in the greatest need of attention after deployments in Iraq and Afghanistan.”

Golick’s father-in-law, Bob Golick, said in an interview she had recently expelled Wong from the program.

The Pathway Home is located on the sprawling campus of the veterans center, which cares for about 1,000 elderly and disabled vets. It is the largest veterans home in the nation, according to the state Department of Veterans Affairs.

Wong went to the campus about 53 miles north of San Francisco on Friday morning, slipping into a going-away party for some employees of the Pathway House.

Larry Kamer told the Associated Press his wife, Devereaux Smith, called him to say the gunman had entered the room quietly, letting some people leave while taking others hostage.

A Napa Valley sheriff’s deputy exchanged gunshots with the hostage-taker at about 10.30am but after that nothing was heard from Wong or his hostages despite efforts to contact him, authorities said.

Army veteran and home resident Bob Sloan, 73, was working at the home’s TV station when a co-worker came in and said he had heard four gunshots coming from the Pathway Home. Sloan sent alerts for residents to stay put.

A group of about 80 students who were on the home’s grounds were safely evacuated after being locked down, Napa County sheriff John Robertson said. The teens from Justin-Siena High School were at a theater rehearsing a play.

“They were a distance away from the shooting situation,” Robertson said.

The bodies of Wong and the women were found at about 6pm. While authorities had the building under siege for about eight hours they did not enter it. Wong’s rental car was later found nearby. A bomb-sniffing dog alerted authorities to something on the car but the only thing found was a cellphone, authorities said.

Yvette Bennett, a wound-care supply worker who supplies the veterans center, was turned back when she tried to deliver what she called urgently needed medical supplies for two patients inside. Of all the medical institutions she has worked with, “this is the most placid, calm, serene place”, she said. Earlier this week, when she last visited, she asked a doctor: “What’s your magic here?”

“And then 48 hours later this happens,” Bennett said.