As a doctor, one of the hardest parts of my job is death. During my short time in residency, I’ve been present at several.

One of my patients came to the intensive care unit with pneumonia on top of chronic pulmonary disease so severe that she carried an oxygen canister to help her breathe. In our care, she was making significant strides with the help of a face mask that would pump massive amounts of air to her nose and mouth. But she had to stay in the hospital until we could get her back to her home oxygen settings.

One day after rounds, I sat with her as she told me she wanted to die. She wanted to see all of her family, have her favorite French vanilla ice cream as her last meal, and then turn off the oxygen.

We did all we could to contact her family members, and surrounded by their love, she died exactly as she wanted. The experience was solemn, yet it also felt joyous, a celebration of a life well-lived.

Another patient had a far different end-of-life story.

He came to the hospital after suffering a massive heart attack. We coaxed his heart into beating again, and cooled his body to give his brain a better chance at surviving. But his pupils dilated and his arms stiffened –both signs of impending brain death.

He depended entirely on a ventilator to breathe, and powerful medications to keep his heart beating. Yet there was almost no chance of recovery. We reached out to his family members for guidance. Some understood how grave the situation was. Others hoped the twitches and reflexes we had seen were signs of recovery. Weeks passed, with no change in his condition.

I tried to help by asking questions that I hoped would yield a better sense of who he was and what he may have wanted. Would he want a breathing tube, to be tethered to oxygen? A feeding tube that meant the end of his favorite foods?

The family had no idea. He was fairly young and had seemed healthy. He never talked about end of life choices.

After several more weeks, the family allowed us to turn off the machines. He died quietly.

It is so hard for families to make that call on behalf of a loved one when when they can see him breathing and feel a pulse. At times like this, there is a huge gray area between doing something for the patient and doing something for their loved ones. Sometimes the best we can do is provide clarity and perspective to help families find their way through the gray.

I went into emergency medicine to save lives, and that goal has never wavered. What I have come to recognize, though, is that at times the medicine patients need most is having at least some say over how they die.

That first patient told us exactly what she wanted, and was able to leave her family with an enormous sense of comfort no one else could give them. But the younger man with the heart attack had no ability to do the same. He could only leave the arduous task of piecing together remembered conversations, actions, and values into a decision that seemed to leave them all feeling unsettled.

There is no way I could witness these kinds of experiences without thinking about my own life. Having seen both sides, I know now that given the choice, I would spend my last days with loved ones at home, not under the fluorescent hospital lights.

Neil A. Ray is an emergency medicine resident in the Perelman School of Medicine at the University of Pennsylvania. The opinions expressed in this article do not represent those of the University of Pennsylvania Health System or the Perelman School of Medicine.