On the day before my mother died, she gave my father a list of demands. He wrote them on the back of an envelope and showed them to me as he left the intensive care unit. There, in his clear block handwriting, it read:

CREAM

WHISKEY

HEROIN

My mother was not herself. And yet, she was completely herself. When Mom’s liver stopped working, her brain, which we had always considered loopy, grew addled. But she was still funny. She hallucinated monkeys on unicycles circling her bed. She learned that Michael Jackson had died, “probably from all that plastic surgery,” she said. She remembered Sarah Palin, and thought she was a twit.

Mom died, at 67, in 2009, but lately I’ve been reflecting on her last days. I’m applying to medical school, and her story keeps coming up in my essays and interviews. Her death spurred me to apply, partly because it gave me courage — nothing in med school could be worse than watching the way my mother died. Her death was so grisly that I vowed to help change the way people die in America.

Mom had a chronic liver condition, an autoimmune disease that had been under control for years but suddenly worsened. After her liver failed, her kidneys followed, then her lungs. After four months in the I.C.U. she was on 24-hour dialysis, with a breathing tube down her throat and a feeding tube up her nose. She hated all the tubes; her hands were tied to the bed so she couldn’t pull them out.

She needed a liver transplant, but was too sick to survive one. Then a fungal infection invaded her lungs, dodged the antibiotics and spread through her body. On a Friday afternoon in August, our family met with the doctors. If we left Mom on life support, the fungus would eat her alive, putrefying her innards, turning her fingers black. It would be a cruel death, they said.

It’s already been a cruel death, I thought.

We decided to let Mom go.

And so there we were, standing at the edge of my mother’s life. After the nurse removed the tubes and machines, we gathered around the hospital bed. The doctors didn’t know how long she could live without life support — somewhere between 15 minutes and a week. We didn’t tell her she was dying, but she understood. A nurse for 28 years, she knew the game was up. But she was happy, thrilled to be off the ventilator. She talked, made jokes, greedily sucked on mouth swabs soaked in ginger ale. The television played soft piano music and looped pictures of sunsets and mountains, birds and flowers. The C.A.R.E. channel, it was called — “continuous ambient relaxation environment.” That was good for some laughs. Maybe this won’t be so bad, I thought.

It got dark. Most of the family went out for a break, leaving my brother, uncle and me with Mom. Moments later, her face crumpled into despair. As we held her hands, she sobbed silently, turning her head from side to side. She didn’t speak. She just wept.

She wept for fear of death, for the betrayal of her body, for the hopelessness of it all. She wept for the places she would never visit, the retirement she never had. She wept for her only grandchild — my son — who would not remember her, for the second grandchild in my pregnant belly whom she would never meet.

I have never seen such anguish. I have never felt so helpless. My stomach churned in panic. I had no experience with death, or consoling the dying. The only person I knew how to comfort was my 18-month-old son.

“Do you want to hear a song?” I asked.

My mother, crying silently, nodded yes.

“Here’s one that Finny likes.”

I took a breath and blurted it out:

Three little speckled frogs

Sitting on a speckled log

Eating the most delicious bugs —

Yum! Yum!

One jumped into the pool,

Where it was nice and cool,

Now there are two speckled frogs!

I danced around the darkened hospital room. Blub blub! Mom rolled her eyes.

By the next evening Mom was on a steady morphine drip, drifting in and out of consciousness. She slept fitfully, her hands fluttering toward her face, touching her forehead, then resting on her chest. Occasionally she opened her eyes and stared at her hands uncomprehendingly. They were knobbed with arthritis, yellowed with jaundice; already the hands of a corpse.

When she woke up, my sister and I went to the bed. Hi Mom, I said. Are you in pain?

She squinted at me, then rolled her eyes. “Why are you still here?” she asked. “You’re crazy!” Watch out, I warned, or I’ll sing the frog song again. She smiled and fell asleep.

My mother’s room, on a top floor of a major university teaching hospital near Boston, had a large picture window. Through it, I could see the roof of the building next door, and beyond that the lake where my sister and I had learned to sail. On the rooftop an orange windsock swelled in the breeze. It was illuminated somehow, and strangely beautiful. I sat next to the window, dozing.

I dreamed about Ted Kennedy. He had died a few days earlier, and his memorial services had blanketed the Boston news. I was jealous of Kennedy. He spent his last days at home, smelling the salt of the ocean. He ate bowls of butter crunch ice cream, watched James Bond movies and shared dinner with friends.

I’m sure Kennedy’s death had its share of horror, but that didn’t curb my envy. Teddy got ice cream; my mom got a sterile sponge soaked in warm ginger ale. Ted got the ocean; Mom got a gritty rooftop with a windsock. Ted got his own bed and movies; Mom got the blinking lights of the I.C.U. and the stupid C.A.R.E. channel. Her TV didn’t even have good reception.

She did not regain consciousness, and died the next morning. I made peace with her death, but not with her dying. She had four months in the I.C.U., endless and pointless and painful procedures, and final days full of fear and despair. Why is this medicine’s default death for so many people?

Now, seven years later, as I apply for medical school, the question comes up again and again. I suppose I should have devised some pat answers by now, prepared my bullet points. But I haven’t.

My mother’s brutal death exposes so many flaws in American medicine: our lack of palliative care, our unwillingness to face end-of-life decisions, our inability to stop the procedures and just let go. Her death was a system failure, and as a doctor I don’t know how I alone can fix the system. I know only that I will try.

Barbara Moran is a science writer in Brookline, Mass. This is the final essay in this series.