LOS ANGELES (AP) — A man armed with a knife was shot and killed by Los Angeles police at an apartment building, authorities said Tuesday.

The shooting happened Monday after officers responded in the Westlake neighborhood for a domestic violence restraining order violation, police said in a statement.

The officers spoke with the suspect, a man in his 40s, who refused to come out of an apartment and then “armed himself with a large knife,” the police statement said.

After officers used pepper spray and a stun gun, the man briefly dropped the knife but immediately picked it up again, police said. Officers then shot the unidentified man, who died at the scene, the statement said.

To the north in Kern County, deputies shot and killed a man described as suicidal who was armed with a gun, sheriff’s officials said in a statement.

Deputies with the Kern County Sheriff’s Office responded shortly before 2:30 a.m. Tuesday to assist the Ridgecrest Police Department, the statement said.

“During the investigation, an officer involved shooting occurred,” the sheriff’s department statement said, without offering additional details on what prompted deputies to open fire.

The unidentified man died at a hospital.

Both shootings were under investigation.