Ridgecrest - An 18-day manhunt in the mountainous high desert of central California ended when two deputies opened fire on a man who pulled out a handgun during a confrontation on a rural road, authorities said on Sunday.Benjamin Peter Ashley, aged 34, was struck by several rounds after he failed to comply with orders to drop the weapon as he walked toward foothills east of Bakersfield on Saturday, Kern County Sheriff Donny Youngblood told The Associated Press.Ashley, who was suspected of killing a retired dentist, taking three men hostage and wounding two deputies, may have turned the 9 mm handgun on himself after being shot by the deputies, Youngblood said. An autopsy planned for Monday will determine the cause of death."He either died from his injuries, or he shot himself and died. It's hard to confirm at this point," Youngblood said.Three other weapons, including a pair of .44-caliber handguns, were found on Ashley's person and in a backpack he was carrying, the sheriff said.The confrontation came after the owner of a rural convenience store reported that a man matching Ashley's description had come in and bought about $100 worth of junk food."He was dirty. He looked like he had been hiking for days," Gary Welfl, the owner of Brady's Mini-Mart in Inyokern, told KERO-TV.Dozens of deputies and officers from various agencies had been searching in remote terrain about 50km east of Bakersfield for Ashley, who was described as a homeless man.Ashley was suspected in a crime spree that began on July 28 when a gunman took three men hostage in a cabin in the Twin Oaks area after they confronted him about squatting on their property. Authorities said the suspect held the men for more than an hour and threatened to kill them before they escaped.The search intensified two days later when David Markiewitz, aged 64, a retired dentist, was found dead in another cabin in Jawbone Canyon, about 16km away.On August 1, two Swat team members were shot and wounded by a shotgun-wielding man as they searched a mobile home in Kelso Valley for Ashley. One deputy was shot in both arms, and the other was grazed.During the manhunt, authorities warned residents to stay inside and lock their doors and windows. Two elementary schools and a middle school were shut. Authorities also closed a stretch of the famed Pacific Crest Trail in the southern Sierra Nevada during the manhunt.The 13-square-kilometre search area is dotted with unoccupied homes and trailers, outbuildings, abandoned mines and caves and other hiding places.Youngblood said detectives were searching for a motive."The investigation continues, but why he did what he did may never be known," he said.