ENCINITAS  Evan Kwik’s potent mix of mental illness and heroin abuse was a constant source of terror for his family, who often became the target of his destructive outbursts and suicide threats.

His rage peaked Wednesday, culminating in a 10-hour SWAT standoff at his mother’s Encinitas home that left two sheriff’s deputies wounded and the 22-year-old dead with a self-inflicted gunshot wound.

Deputy Colin Snodgrass, 27, who was shot in the knee, and Deputy James Steinmeyer, 31, who was grazed on the forehead, were continuing to recover Thursday and are lucky to have survived, sheriff’s officials said.

The violent confrontation was foreshadowed in a temporary restraining order filed by Kwik’s mother just a week ago, in which she warned that he wants “suicide by cop” and will protect himself with knives and bear spray.

“I truly believe there is a very large chance he will die on his own or maybe take his own life,” Michelle Kwik wrote in the Feb. 14 Vista Superior Court documents. “He is better off in jail than in a grave. Please help me help him.”

When his mother called deputies to her home on Del Rio Avenue Wednesday afternoon, they were expecting him to be armed with the knife or bear spray. Not a shotgun.

Michelle called 911 about 1 p.m. to report her son had come by, upset over the restraining order, and stole her car. The deputies responded, but he wasn’t there. They returned about 3:30 p.m., and so had he.

Kwik hid in the attic of his mother’s house, made threats and refused orders to come out. Deputies fired tear gas into the crawl space to try to put an end to the escalating situation.

Steinmeyer, who was among a group of deputies inside the house, popped his head through the trap door to get a visual on Kwik but couldn’t see him. He looked a second time and was met with shotgun blasts.

Shrapnel struck him on the forehead. Kwik then fired at least five other shots. Rounds sent through the attic floor didn’t find a target, but a shot out of an exterior vent went though a neighbor’s fence and struck Snodgrass in the knee as he held a perimeter on the home.

Another deputy, who had served in the military, dove on top of Snodgrass, protecting the downed deputy with her body. A third deputy who had just received trauma care training cranked down a tourniquet over Snodgrass’ leg to stop the gushing blood.

“It worked. It worked well,” said Encinitas Capt. Robert Haley. “It just chokes you up to see their bravery and how they handle stress. They’re all incredibly calm.”

No deputies returned fire because they couldn’t exactly see Kwik’s location and they didn’t know if there was anyone else inside the home, said homicide Capt. Duncan Fraser.

Members of the Carlsbad police SWAT team were the first crisis negotiators to arrive, and law enforcement officers from around the county responded to the call of “officer down.”