A man accused of killing two teachers and wounding two other people in a shooting rampage was released from a hospital Friday and transferred to jail, where he was being held without bail on two counts of murder and two counts of attempted murder, authorities said.

Christopher A. Williams, a 26-year-old bakery worker, allegedly set out to kill his ex-girlfriend but could not find her during Thursday's shooting spree.

As police closed in, he shot himself twice in the head but was still lucid enough to talk to police who arrested him, said Police Chief David Demag.

The shootings began around 2 p.m., when Williams showed up at the home he shared with ex-girlfriend Andrea Lambesis and her mother, Linda Lambesis, 57, according to Police Chief David Demag.

Williams shot the elder woman to death, then went to Essex Elementary School in search of her daughter, Demag said. Though the school was still in summer recess, about 39 staffers were working — including the younger Lambesis, a teacher. It was not clear where she was in the building, but Williams did not find her.

He opened fire on two other people instead, fatally shooting teacher Mary Shanks, 56, and wounding employee Mary Snedeker, 52, Demag said.

Some employees were seen running from the school, heads ducked, while others hid.

While police commando teams and sheriff's deputies were searching the halls, Williams escaped and went to the condominium complex where acquaintance Chad Johansen, 26, lives, police said. Their relationship was unclear Thursday.

Jillian Schultz, 22, a resident of the condominiums, said a sweaty and disheveled Williams called out "Where's Chad? Where's Chad?" as he ran by her. Schultz was in the yard playing with her 13-month-old son and Johansen's 2-year-old son at the time.

Moments later, she heard four gunshots and saw bullets rip through bushes 10 feet (3 meters) away. Then she saw Johansen come toward the building, bleeding from the back and yelling to her to call aulthorities.

The shootings occurred hours after Williams stole his ex-girlfriend's car, did not show up for work and then returned the car without making contact with her, he said.

It was not clear what triggered the rampage, according to Demag and acting State's Attorney Margaret Vincent.

"It was a dispute and that's what set the events in that motion," Demag said.

Williams could be charged Friday, Vincent said.

Johansen was listed in fair condition at Fletcher Allen Health Care, spokesman Mike Noble said. Snedeker was being evaluated.