Eighty percent of terminally ill patients say they want to avoid hospitalization and intensive care at the end of their lives. But such hospital stays nevertheless occur fairly frequently ― even though they don’t seem to make much difference. Studies have shown that people who received less intense care in the last six months of life did not have a higher mortality rate than people who received more intense care.

So it’s worth asking why elderly and terminally ill patients are put through stressful hospitalizations, procedures and medical tests that only wind up blemishing their final days.

One reason: Hospitals can do it, and Medicare will pay for it.

A report from the Dartmouth Institute for Health Policy and Clinical Practice notes that “the intensity of care in the last six months of life is an indicator of the propensity to use life-saving technology.” The institute found that if you live in an area that has a big teaching hospital with the latest medical equipment, chances are you’ll spend more of your final days admitted to it. In 2014, patients in Boise, Idaho, spent 3.9 days of the last six months of their lives hospitalized, compared to 13.7 days for New York City patients.

Some patient advocates and chronically ill patients want to reduce end-of-life hospitalizations through the use of advance care planning directives. The most common of these is the “do not resuscitate” order, which instructs the hospital and doctors that if your heart stops beating or you stop breathing, you do not wish to have CPR. Absent such a directive, hospital staff will try to help any patient whose heart or breathing has stopped.

Far less common ― but potentially much further-reaching ― are “do not hospitalize” directives, which stipulate that you don’t want your caregivers to take you to the hospital for care. A recent study found that these orders are indeed effective at preventing unwanted hospitalizations.

A small research study of nursing home residents in New York state found that overall, 6 percent of residents had DNH orders. Of those people, just 3 percent spent time in a hospital during their last 90 days of life, compared to 6.8 percent of people in the study who did not have a DNH order. In other words, the people who did not have an order were more than twice as likely to be hospitalized.

On a practical level, having a directive that says you don’t want to be admitted to a hospital ― except under certain conditions, specified by you ― basically means a nursing home or family caregiver will do what they can to treat you and let nature take its course. Hospice care is available through Medicare as well.