Excerpted from Being Mortal: Medicine and What Matters in the End, by Atul Gawande, published on Tuesday by Macmillan.

I learned about a lot of things in medical school, but mortality wasn’t one of them.

Although I was given a dry, leathery corpse to dissect in anatomy class in my first term, our textbooks contained almost nothing about aging or frailty or dying. The purpose of medical schooling was to teach how to save lives, not how to tend to their demise.

I had never seen anyone die before I became a doctor, and when I did, it came as a shock. I’d seen multiple family members—my wife, my parents, and my children—go through serious, life-threatening illnesses, but medicine had always pulled them through. I knew theoretically that my patients could die, of course, but every actual instance seemed like a violation, as if the rules I thought we were playing by were broken.

Dying and death confront every new doctor and nurse. The first times, some cry. Some shut down. Some hardly notice. When I saw my first deaths, I was too guarded to weep. But I had recurring nightmares in which I’d find my patients’ corpses in my house—even in my bed.

I felt as if I’d failed. But death, of course, is not a failure. Death is normal. Death may be the enemy, but it is also the natural order of things. I knew these truths abstractly, but I didn’t know them concretely—that they could be truths not just for everyone but also for this person right in front of me, for this person I was responsible for.

You don’t have to spend much time with the elderly or those with terminal illness to see how often medicine fails the people it is supposed to help. The waning days of our lives are given over to treatments that addle our brains and sap our bodies for a sliver’s chance of benefit. These days are spent in institutions—nursing homes and intensive-care units—where regimented, anonymous routines cut us off from all the things that matter to us in life.

As recently as 1945, most deaths occurred in the home. By the 1980s, just 17 percent did. Lacking a coherent view of how people might live successfully all the way to the very end, we have allowed our fates to be controlled by medicine, technology, and strangers.

But not all of us have. That takes, however, at least two kinds of courage. The first is the courage to confront the reality of mortality—the courage to seek out the truth of what is to be feared and what is to be hoped when one is seriously ill. Such courage is difficult enough, but even more daunting is the second kind of courage—the courage to act on the truth we find.

A few years ago, I got a late night page: Jewel Douglass, a 72-year-old patient of mine receiving chemotherapy for metastatic ovarian cancer, was back in the hospital, unable to hold food down. For a week, her symptoms had mounted: They started with bloating, became waves of crampy abdominal pain, then nausea and vomiting.

Her oncologist sent her to the hospital. A scan showed that, despite treatment, her ovarian cancer had multiplied, grown, and partly obstructed her intestine. Her abdomen had also filled with fluid. The deposits of tumor had stuffed up her lymphatic system, which serves as a kind of storm drain for the lubricating fluids that the body’s internal linings secrete. When the system is blocked, the fluid has nowhere to go. The belly fills up like a rubber ball until you feel as if you will burst.

But walking into Douglass’ hospital room, I’d never have known she was so sick if I hadn’t seen the scan. “Well, look who’s here!” she said, as if I’d just arrived at a cocktail party. “How are you, doctor?”

“I think I’m supposed to ask you that,” I said.

She smiled brightly and pointed around the room. “This is my husband, Arthur, whom you know, and my son, Brett.” She got me grinning. Here it was, 11 at night, she couldn’t hold down an ounce of water, and she still had her lipstick on, her silver hair was brushed straight, and she was insisting on making introductions.

Her oncologist and I had a menu of options. A range of alternative chemotherapy regimens could be tried to shrink the tumor burden, and I had a few surgical options too. I wouldn’t be able to remove the intestinal blockage, but I might be able to bypass it, I told her. Or I could give her an ileostomy, disconnecting the bowel above the blockage and bringing it through the skin to empty into a bag. I would also put in a couple of drainage catheters—permanent spigots that could be opened to release the fluids from her blocked-up drainage ducts or intestines when necessary. Surgery risked serious complications—wound breakdown, leakage of bowel into her abdomen, infections—but it was the only way she might regain her ability to eat.

I also told her that we did not have to do either chemo or surgery. We could provide medications to control her pain and nausea and arrange for hospice care at home.

This is the moment when I would normally have reviewed the pros and cons. But we are only gradually learning in the medical profession that this is not what we need to do. The options overwhelmed her. They all sounded terrifying. So I stepped back and asked her a few questions I learned from hospice and palliative care physicians, hoping to better help both of us know what to do: What were her biggest fears and concerns? What goals were most important to her? What trade-offs was she willing to make?

Not all can answer such questions, but she did. She said she wanted to be without pain, nausea, or vomiting. She wanted to eat. Most of all, she wanted to get back on her feet. Her biggest fear was that she wouldn’t be able to return home and be with the people she loved.

I asked what sacrifices she was willing to endure now for the possibility of more time later. “Not a lot,” she said. Uppermost in her mind was a wedding that weekend that she was desperate not to miss. “Arthur’s brother is marrying my best friend,” she said. She’d set them up on their first date. The wedding was just two days away. She was supposed to be a bridesmaid. She was willing to do anything to make it, she said.

Suddenly, with just a few simple questions, I had some guidance about her priorities. So we made a plan to see if we could meet them. With a long needle, we tapped a liter of tea-colored fluid from her abdomen, which made her feel at least temporarily better. We gave her medication to control her nausea. We discharged her with instructions to drink nothing thicker than apple juice and to return to see me after the wedding.

She didn’t make it. She came back to the hospital that same night. Just the car ride, with its swaying and bumps, made her vomit, and things only got worse at home.

We agreed that surgery was the best course now and scheduled it for the next day. I would focus on restoring her ability to eat and putting drainage tubes in. Afterward, she could decide if she wanted more chemotherapy or to go on hospice.

She was as clear as I’ve seen anyone be about her goals, but she was still in doubt. The following morning, she canceled the operation. “I’m afraid,” she said. She’d tossed all night, imagining the pain, the tubes, the horrors of possible complications. “I don’t want to take risky chances,” she said.

Her difficulty wasn’t lack of courage to act in the face of risks; it was sorting out how to think about them. Her greatest fear was of suffering, she said. Couldn’t the operation make it worse rather than better?

It could, I said. Surgery offered her the possibility of being able to eat again and a very good likelihood of controlling her nausea, but it carried substantial risk of giving her only pain without improvement or adding new miseries. She had, I estimated, a 75 percent chance that surgery would make her future better, at least for a little while, and a 25 percent chance it’d make it worse.

The brain gives us two ways to evaluate experiences like suffering—how we apprehend such experiences in the moment and how we look at them afterward. People seem to have two different selves—an experiencing self who endures every moment equally and a remembering self who, as the Nobel Prize–winning researcher Daniel Kahneman has shown, gives almost all the weight of judgment afterward to just two points in time: the worst moment of an ordeal and the last moment of it. The remembering self and the experiencing self can come to radically different opinions about the same experience—so which one should we listen to?

This, at bottom, was Jewel Douglass’ torment. Should she heed her remembering self—or, in this case, anticipating self—which was focused on the worst things she might endure? Or should she listen to her experiencing self, which would likely endure a lower average amount of suffering in the days to come if she underwent surgery rather than just going home—and might even get to eat again for a while?

In the end, a person doesn’t view his life as merely the average of its moments—which, after all, is mostly nothing much, plus some sleep. Life is meaningful because it is a story, and a story’s arc is determined by the moments when something happens. Unlike your experiencing self, which is absorbed in the moment, your remembering self is attempting to recognize not only the peaks of joy and valleys of misery but also how the story works out as a whole. That is profoundly affected by how things ultimately turn out. Football fans will let a few flubbed minutes at the end of a game ruin three hours of bliss—because a football game is a story, and in stories, endings matter.

Jewel Douglass didn’t know if she was willing to face the suffering that surgery might inflict and feared being left worse off. “I don’t want to take risky chances,” she said. She didn’t want to take a high-stakes gamble on how her story would end. Suddenly I realized, she was telling me everything I needed to know.

We should go to surgery, I told her, but with the directions she’d just spelled out—to do what I could to enable her to return home to her family while not taking “risky chances.” I’d put in a small laparoscope. I’d look around. And I’d attempt to unblock her intestine only if I saw that I could do it fairly easily. If it looked risky, I’d just put in tubes to drain her backed-up pipes. I’d aim for what might sound like a contradiction in terms: a palliative operation—an operation whose overriding priority was to do only what was likely to make her feel immediately better.

She remained quiet, thinking.

Her daughter took her hand. “We should do this, Mom,” she said.

“OK,” Douglass said. “But no risky chances.”

When she was under anesthesia, I made a half-inch incision above her belly button. I slipped my gloved finger inside to feel for space to insert the fiberoptic scope. But a hard loop of tumor-caked bowel blocked entry. I wasn’t even going to be able to put in a camera.

I had the resident take the knife and extend the incision upward until it was large enough to see in directly and get a hand inside. There were too many tumors to do anything to help her eat again, and now we were risking creating holes we’d never be able to repair. Leakage inside the abdomen would be a calamity. So we stopped.

No risky chances. We shifted focus and put in two long, plastic drainage tubes. One we inserted directly into her stomach to empty the contents backed up there; the other we laid in the open abdominal cavity to empty the fluid outside her gut. Then we closed up, and we were done.

I told her family we hadn’t been able to help her eat again, and when Douglass woke up, I told her too. Her daughter wept. Her husband thanked us for trying. Douglass tried to put a brave face on it. “I was never obsessed with food anyway,” she said.

The tubes relieved her nausea and abdominal pain greatly—“90 percent,” she said. The nurses taught her how to open the gastric tube into a bag when she felt sick and the abdominal tube when her belly felt too tight. We told her she could drink whatever she wanted and even eat soft food for the taste. Three days after surgery, she went home with hospice care to look after her.

Before she left, her oncologist and oncology nurse practitioner saw her. Douglass asked them how long they thought she had. “They both filled up with tears,” she told me. “It was kind of my answer.”

A few days later, she and her family allowed me to stop by her home after work. She answered the door, wearing a robe because of the tubes, for which she apologized. We sat in her living room, and I asked how she was doing.

OK, she said. “I think I have a measure that I’m slip, slip, slipping,” but she had been seeing old friends and relatives all day, and she loved it. She was taking just Tylenol for pain. Narcotics made her drowsy and weak, and that interfered with seeing people.

She said she didn’t like all the contraptions sticking out of her. But the first time she found that just opening a tube could take away her nausea, she said, “I looked at the tube and said, ‘Thank you for being there.’ ”

Mostly, we talked about good memories. She was at peace with God, she said. I left feeling that, at least this once, we had done it right. Douglass’ story was not ending the way she ever envisioned, but it was nonetheless ending with her being able to make the choices that meant the most to her.

Two weeks later, her daughter Susan sent me a note. “Mom died on Friday morning. She drifted quietly to sleep and took her last breath. It was very peaceful. My dad was alone by her side with the rest of us in the living room. This was such a perfect ending and in keeping with the relationship they shared.”

I am leery of suggesting that endings are controllable. No one ever really has control; physics and biology and accident ultimately have their way in our lives. But as Jewel Douglass taught me, we are not helpless either—and courage is the strength to recognize both of those realities. We have room to act and shape our stories—although as we get older, we do so within narrower and narrower confines.

That makes a few conclusions clear: that our most cruel failure in how we treat the sick and the aged is the failure to recognize that they have priorities beyond merely being safe and living longer; that the chance to shape one’s story is essential to sustaining meaning in life; and that we have the opportunity to refashion our institutions, culture, and conversations to transform the possibilities for the last chapters of all of our lives.