The former Army infantryman who authorities said shot and killed three people at the Veterans Home of California had been dismissed from a program at the facility not long before the shooting, a state senator said.

Authorities said Albert Wong, 36, arrived at the veterans facility in Yountville on Friday morning with a rifle and exchanged gunfire with a sheriff’s deputy before crashing a farewell party for employees and taking captives.

A tense standoff between Wong and the police came to a grim end when officers entered the room he was in to find him and three women dead.

Christine Loeber, 48; Jennifer Golick, 42; and Jennifer Gonzales, 29, were killed. Loeber was the executive director of The Pathway Home, a nonprofit that reintegrates veterans into civilian life. Golick was a clinical director and Gonzales a clinical psychologist with the San Francisco VA Health Care System.

The confrontation stretched throughout the day Friday and into the evening. Teams of federal, state and local law enforcement officials and hostage negotiators from three agencies had been unable to make contact with the gunman or the hostages throughout the day, officials said.

But about 6 p.m. local time, officers entered the room and discovered the bodies of the three women and Wong, dead of apparent gunshot wounds.

“We are deeply saddened by the tragic situation in Yountville and mourn the loss of three incredible women who cared for our Veterans,” President Trump said in a Saturday post on Twitter.

Veterans Affairs Secretary David Shulkin also gave his condolences late Friday night. “We are deeply saddened and affected by the tragic outcome of the hostage situation at the Veterans Home of California in Yountville and extend our deepest condolences to the loved ones involved,” Shulkin said.

California Gov. Jerry Brown (D) ordered flags flown at half-staff at the capitol in memory of the victims.

Wong served in the Army as an infantryman with one tour in Afghanistan from 2011-2012, the Associated Press reported.

State Sen. Bill Dodd (D), who represents the area, said on NBC that the gunman had been dismissed from a veterans program at the facility this week.

Bob Golick said in a Friday afternoon interview with the Associated Press that his daughter-in-law, Jennifer Golick, called his son around 10:30 a.m. that day to say she had been taken hostage in the building where she worked. The son, Mark Golick, is Jennifer Golick’s husband.

“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,” The Pathway Home said in a statement.

The incident began to unfold around 10:20 a.m., when Wong exchanged fire with a sheriff’s deputy who had been called to the scene, officials said.

“There was a going-away party for a couple of the staff who were leaving today. Today was their last day. They were having cake and toasting, and apparently he just walked in with this rifle,” said Larry Kamer, who told reporters that his wife, an employee for The Pathway Home, was at the event.

Kamer said his wife was one of the captives who had been allowed to leave.

The standoff lasted about eight hours, paralyzing the complex and nearby areas. Law enforcement officers from state and federal agencies had swarmed around the building as worried family members waited outside. Those inside were told to shelter in place.

The scene brought terror to the town of about 3,000 in the heart of California’s wine country, as armored vehicles descended on Yountville, perhaps most famous for the upscale restaurant The French Laundry. The winery Domaine Chandon is less than a half-mile away from the veterans home.

And it was another trauma for an area still recovering from devastating wildfires in October. The veterans home had been evacuated during the fires.

Some 80 high school students visiting a theater on the property of the veterans home were put in a “lockdown situation” before being evacuated, Napa County Sheriff John R. Robertson told reporters. Nearby facilities, including a golf course, were also evacuated.

Law enforcement agents from the FBI and the Bureau of Alcohol, Tobacco, Firearms and Explosives assisted in the response, joining deputies from the Napa County Sheriff’s Office as well as a SWAT team from the highway patrol.

Fernando Juarez of Napa embraces sister Vanessa Flores at the Veterans Home of California on Friday. Flores, a caregiver at the facility, exchanged texts with family while she hid. (Ben Margot/Associated Press)

Photographs from local media outlets showed armored vehicles and officers in tactical gear at work outside the building.

The Yountville residence is home to 1,000 elderly or disabled veterans, some who fought in World War II, and dates to the 1880s, according to the California state VA Department. It is the largest veterans home in the United States.

The Pathway Home occupies part of the massive campus. The organization opened in 2008 to work with male soldiers returning from the wars in Iraq and Afghanistan, including a large number dealing with post-traumatic stress disorder, the San Francisco Chronicle reported.

It is known for unconventional treatments such as swimming with dolphins and social events where veterans mix with children. Since it opened, about 450 people have been treated there for PTSD, mild traumatic brain injury and other mental health problems, the Chronicle reported.