Jeffrey Davitz is a scientist and Silicon Valley entrepreneur focused on artificial intelligence. He lives in California.

In April 2015, at the age of 55, I was diagnosed with one of the most lethal and aggressive brain tumors, a brainstem glioblastoma multiforme in an advanced stage. The prognosis was both grim and precise: Without treatment, I might have a few months; with treatment, I could last six months. If I beat overwhelming odds, I'd toast the new year one last time.

During the time my doctors were converging on my cancer diagnosis, interest was building here in California for a law, called "aid in dying," that would allow physicians to help patients end their lives. The effort had received a significant boost from the publicity around Brittany Maynard , a 29-year-old woman who had a prognosis similar to mine. She ended her life in 2014, before any legislative action in California, by relocating to Oregon, establishing residency and taking advantage of the Death With Dignity law there. Before that, she used her time to become a reasonable, driven and passionate advocate for right-to-die laws. Perhaps affected by her powerful advocacy, the California legislature passed the aid-in-dying law and Gov. Jerry Brown signed it on Oct. 5, 2015, early in the window of my expected demise.

I did not spend any time navigating the five stages of grief. I decided on treatment, which would be followed by palliative care and hospice. I quickly knew — it could hardly be called a decision — that I would not allow the cancer to force an awful ending on my family and me. My big fear, probably shared by most in my situation, was that I would wait too long to be able to carry out my responsibility under the law. The terms are quite specific, saying the patient is the only one permitted to take any action leading to death. I'd have to endure the final suffering if I became paralyzed or otherwise incapacitated.

[Study finds that existential distress, not pain, leads people to assisted suicide.]

Preparations under the law are remarkably simple: a one-page form with some text and room for a few signatures. A doctor I knew assured me that he would help me with the signatures and prescriptions, so I'd be able to access the drugs if my provider network elected not to participate. I was prepared to pay for it out of pocket if I had to. My father agreed, privately weeping, to deliver the drugs in the house to me in case I couldn't manage and needed to act.

Then, I learned that while the aid-in-dying law had been enacted, it contained a procedural delay: It would not be effective until the following June, in 2016, long past my predicted death. I decided I wasn't going to move to Oregon or another state that permitted assisted suicide, since it would eventually be legal in my state. I would wait if I could, and I would use extralegal means if I began to slip beforehand. I talked with my brother about logistics and other arrangements; we picked a place and time. I would use the morphine in my hospice kit and would attempt the overdose when my brother was in the house with me, so he could handle the aftermath and spare anyone else shock. We assumed I would go through with it sometime in November or December, about seven months after my diagnosis. I was ready.

I did not feel terrible at the time. On the contrary, I seemed to be doing okay, even well on some days, but I knew that brain cancer typically accelerates quickly, and the decline is precipitous. As I waited for the law to go into effect, I began to feel some creeping uncertainty about my decision to die. There were things I still wanted to do, like see my daughter's high school graduation. I was ready to go, I thought, and yet I was conflicted.

Then a peculiar thing happened: I started to get better.

I came back to the world, hesitantly at first. I noticed that I was getting stronger: I had been almost bedridden in the early stages of my illness, too weak to walk. But my strength began to return, and as it did, I felt the dizziness that had come with the diagnosis recede. I regained my balance. Strange symptoms, such as a weird full-body buzz that had begun when I lowered my head, also faded away. Soon, I was having somewhat normal days, doing some professional things, socializing and exercising.

I was an unusual hospice member — eventually the program kicked me out, designating me a "hospice graduate," a label that I still find funny. I celebrated my brother's 60th birthday with him, attended my daughter's graduation, saw my parents hit their 72nd wedding anniversary and fell into a kind of life pattern.

[Should people with acute mental suffering be allowed to die?]

My MRIs reflected this. The tumor stopped its relentless advance, and there were even signs of some retreat. My most recent image, in May, surprised my doctors, who saw signs not of the expected encroachment but of a slowing and even dormant process.

I've now lived longer and better than anybody had projected. Suddenly, it's hard to see self-termination in quite the same way. I could have missed all this.

Before, I considered myself pure in thought, intent and desire. My goals were simple, and my convictions felt strong. I wanted to avoid unnecessary pain, and I did not want my family to be forced to participate in an ugly unwinding. Now I see that those intentions, which I still have, are not my only intentions, and despite their strength and clarity, it isn't obvious which ones must prevail. I still believe in the fundamental right of self-determination through self-termination, but I now feel the weight of its complexity and uncertainty. It is a gamble: Avoid pain at the risk of missing life, or hold on to life at the risk of spreading pain.

Looking back at the moments I didn't know I would have, I can see that my very-near-furious commitment to assisted suicide was driven as much by a need to exert control over my body and fate as it was by a desire to avoid pain. It was a way, my only way, of regaining agency. It was important to protect myself and others from suffering, but I also yearned to ensure that I, not the cancer, was issuing the stage directions.

I am, of course, not alone in these feelings and this motivation. Studies of patients who pursue aid in dying have found that control over their death and maintenance of their autonomy rank highest among their reasons for doing so. One study even found that up to a third of patients who filled their prescriptions under Oregon's Death With Dignity law did not end up taking the medications; merely having them gave these respondents a sufficient sense of control. Another study found that patients who receive prescriptions for lethal medications report less depression and anxiety than those who do not. The gun next to the bed is a comfort.

[Neil Gorsuch wrote the book on assisted suicide. Here’s what he said.]

Yet practical pressures always loom. One does ask questions about the best time, given various schedules: Would it be worse to go before my daughter goes to school or after? It's impossible to ignore your proximity to an expiring-term life insurance policy, which the law requires insurance companies to honor in the case of assisted suicide, that could make the difference between your family's financial health or disaster.

All of these factors cast this decision to live in the murkiest light. Sometimes, I wonder: Would dying have been a good choice anyway? In my case, and not speaking generally, the answer is: of course not. I had a surprising, profoundly unlikely path that has led to love and work of special kinds. I got some good luck in the midst of the bad luck, and I have had a great few years — in some peculiar way the ideal life. Not without pain and difficulties, but also with moments of transcendence.

We do what we can, and luck will, in its own time, usher us on to some other world. The chances are excellent that my original diagnosis is correct (I believe it is) and that at some point, the inevitable will happen, and I will die by my own hand or by fate. But I am not trying to find my way to clear, simple feelings anymore. Instead, long beyond what was expected, I am simply living.

CORRECTION: An earlier version of this article provided an incorrect artist’s credit for the accompanying illustration.

Read more from Outlook and follow our updates on Facebook and Twitter.