Police have shot dead a man believed to be the California quarry worker who killed three colleagues and wounded six others on Wednesday.
Despite a huge Swat-team-led manhunt for Shareef Allman, 47, it was three officers on routine patrol who shot a man matching his description.
They opened fire after the suspect crouched behind a car and brandished a firearm, said the authorities.
A coroner's report must officially confirm his identity.
Schools were locked down earlier in Cupertino, the home of computer giant Apple, and in nearby communities.
Residents were warned to stay indoors as armed police conducted door-to-door searches.
The suspect was shot on Thursday morning in the Sunnyvale neighbourhood, not far from Hewlett-Packard's Cupertino campus.
Santa Clara County Sheriff Laurie Smith told the Los Angeles Times all three police deputies had opened fire.
She said he had "displayed in a threatening manner his firearm" from behind a vehicle.
Jenny Martin told the Associated Press news agency how police had scoured her neighbourhood in search of Allman.
"The Swat stormed in like ninjas, and they took a position in our front bedroom," she said.
It is not clear what may have prompted Allman to snap, but it is said he became upset during a routine safety meeting and left.
He allegedly returned with a rifle and shot dead three male colleagues.
Some of the six people injured in the gun rampage remained in critical condition on Thursday.
A woman shot during an attempted carjacking by a man matching Allman's description was in stable condition in hospital.
Allman's friends said the shooting was completely out of character.
Walter Wilson, a community activist, told AP the last time he had seen Allman he had seemed jovial.
Allman had run a nonprofit group for youths, and written a book about the evils of domestic violence.