When Carol Lewis's father-in-law died, family members circled his hospital bed to pray, expecting to offer their final goodbyes peacefully. Then his body suddenly started to lurch.

"He jumped," said Lewis, a nurse from Hadley, Mass. "Then he jumped again, and again. It kept happening."

Finally, two hospital staffers rushed in and placed a large magnet on the 86-year-old's chest, deactivating a device that doctors had implanted years earlier to zap his ailing heart if it faltered.

"It was very disturbing," said Lewis, whose father-in-law had no hope of recovering from a head injury he had suffered in a fall. "We all found it very upsetting -- so upsetting."

Similar scenes are playing out in intensive-care units, nursing homes, hospices and private homes around the country as the number of people with devices like the one that jolted Lewis's father-in-law has soared.

The implants -- small, internal versions of the paddles that emergency rooms use to shock patients' malfunctioning hearts -- are saving many lives. But in some cases they also are making the act of dying harder, forcing terminally ill patients and families to make wrenching decisions about turning them off. The devices subject some dying patients to painful jolts and can prolong suffering, traumatizing loved ones as the devices fire fruitlessly.

"It can be just awful," said Porter Storey of the American Academy of Hospice and Palliative Medicine. "The thing will shock them and shock them and shock them. Patients describe it as like being kicked in the chest by a horse. Their muscles convulse. If you are holding their hand you may even feel the electricity. It's quite jarring."

The problem is an example of the consequences of medical technologies proliferating before the ethical, psychological and logistic issues they raise have been resolved.

"When new technologies are introduced, they often come with new concerns and dilemmas," said Paul S. Mueller, a doctor and ethicist at the Mayo Clinic who has written about the ethics of deactivating the devices. "We often forget about that."

In response, some hospice nurses have begun carrying magnets in case a patient seeking a peaceful death starts getting shocked. Organizations representing hospices and doctors who implant defibrillators conceded that none has specific policies on handling such cases, although all said they plan to address the question.

Meanwhile, a small coterie of ethicists, palliative-care advocates and heart specialists has begun lobbying hospitals, hospices and nursing homes to quiz patients routinely about whether they have defibrillators and to develop procedures for honoring the wishes of patients who want them deactivated. They also want companies that make the devices to encourage doctors to raise the issue with patients when the devices are implanted.

"We're trying to get this on people's radar screens," said Jennifer Ballentine of the Colorado Hospice Organization in Colorado Springs. "It's more on the radar screen today than it was a few years ago, but we've still got a long way to go."