Authors are told to write what they know, but my own story was, for many years, too hard to even contemplate. I was too scared to explore the emotions I kept locked away. I wrote other books instead – became known for twisty thrillers – then last year I sat at my desk with new resolve. It was time.

In November 2006 I delivered twin boys 12 weeks prematurely. Josh and Alex were baby birds, with screwed-shut eyes and translucent skin. They drank my milk through a narrow tube, breathed via a mask over their tiny faces, and day by day grew stronger.

By the end of our first month in the neonatal intensive care unit (NICU) my husband Rob and I were pros. We told new parents where the fridges were for expressed milk, the quickest route to the canteen and where to buy a parking pass. We were in by seven and home 13 hours later, our days filled with beeps and whirs, and the stillness of a ward where lives hung in the balance.

Hope for the best, they tell you, but prepare for the worst. Stress was a fish bone lodged in my throat and for months I breathed shallow and fearful, as though I might choke. I still get that feeling now, triggered by a photograph, a memory, a hospital corridor.

The boys were breathing, feeding, putting on weight. They wouldn’t be home by Christmas, but perhaps soon after

The boys made excellent progress: breathing, feeding, putting on weight. The consultant was delighted. They wouldn’t be home by Christmas, but perhaps soon after. We began to feel excited about becoming a family.

Hope is a seesaw balanced by despair and it took less than two days to tip from one to the other. Alex picked up an infection called Pseudomonas, and within hours he was being intubated. His temperature was dangerously high; his pulse erratic. He began fitting.

Then they took us into the quiet room. The quiet room had blinds at the window and judiciously placed tissues. The crying room, it should be called, because the news delivered there is never good. We sat on a peach sofa as the consultant told us Alex had bacterial meningitis; the next few days would be critical.

My memory of those days is fragmented: movie scenes I watched through closed fingers. Doctors, lumbar punctures, brain scans. A cocktail of drugs snaking into veins through bruised skin. Then the quiet room again. Walking down the corridor towards it, the consultant a few steps ahead. Afterwards I wondered whether she was silently practising how to break the news.

Alex had suffered a haemorrhage so extensive that no part of his brain was untouched. In time, the consultant said, he might be able to breathe independently, but it was doubtful he would ever walk or talk.

“He’s unlikely to be able to swallow,” she said. Strangely, of all the terrible news delivered in the quiet room, it was this that had the biggest impact on me. “We need you to make a decision about his future.”

I recall the panic starting. Not just for the decision itself but for the act of making it. The weeks in NICU – and, before that, in Maternity, legs crossed against early labour – had lost us our agency. Yet now, when it mattered most, they were handing it back.

The options were both straightforward and impossible. Keep Alex alive or let him die. Seeing it like that, written with such starkness, is as horrific as it felt that day. I recall the sensation of the ground shifting beneath my feet, as though some seismic change were taking place. Whatever we decided, life would never be the same again. The consultant was gentle and compassionate. “You need to imagine two futures,” she said. “One with a profoundly disabled son, one without that son at all.”

I thought of the poem by Robert Frost, The Road Not Taken. “Two roads diverged in a yellow wood / And sorry I could not travel both.” I wanted to see both roads, to know for certain what lay ahead. I wanted to know how the story ended.

Panic bubbled to the surface. Rob and I had been married for three years. We were good at talking things through; at finding a compromise when we disagreed. But here, there could be no compromise.

“What if we don’t agree?” There was the longest pause before the doctor replied. “You have to,” she said, “because the alternative is unthinkable.” It would be to the unthinkable I would return, years later, when I wrote After the End, although it was far from my mind then. Instead I was standing at Frost’s crossroads, trying to see 10 years down each path.

One way: a life without Alex. A family of three instead of four. Our future on this path was unarguably clear, and unarguably painful. When I tried to visualise it, I was overwhelmed by the pain in my heart, so intense I could hardly breathe. The second road was less certain, but no less painful. A child who required round-the-clock care. Who might never have any awareness of the world around him. A child who wouldn’t kick a ball, or climb a tree, or crawl into my lap for a cuddle.

We walked through the hospital grounds, numb with grief. I watched a woman and her partner carry twin babies to their car and felt a sudden rush of bitterness. Why us, not them? I blamed myself for letting the babies come early. We tried to list the arguments for each option, circling endlessly back to the same refrain. I can’t, I just can’t. I called my father, himself a doctor. I told him I needed him, not as a grandfather, but as a medical professional. I can’t imagine how he must have felt and – looking back – it seems horribly unfair to have asked him.

He was calm and wise, and everything I needed. He talked about the Hippocratic oath and the importance of doing no harm. He talked about working with nature, not against it, and he gently suggested we consider not whether Alex might live, but whether that life would be meaningful – not to us, but to him.

Rob and I drove home in silence, trapped in our own nightmares. We talked through the night, falling asleep on the sofa and waking to find our cheeks wet with tears, clinging to each other as though we were drowning.

Back in the quiet room – how I’d grown to hate that room – we told the consultant we wanted to remove Alex from intensive care and let him die.

We brushed his hair and changed his babygro, and packed a lifetime of love into every second

“For what it’s worth,” she said quietly, “I think you’ve made the right decision.” I wondered if she would have said the same if we’d asked to keep him alive, if she was simply giving us the validation we so needed to hear. I hope not, because in the years since I’ve clung to her words for reassurance.

They brought Alex to us, free from machines for the first time since he was born. He won’t feel any pain, they insisted, and I wished there was a drug to do the same for us. I couldn’t tell you how long the three of us sat in that room. I read him stories and sang a lullaby, while all the time I fought to stop my tears, because I didn’t want my boy to see me cry. We brushed his hair and changed his babygro, and packed a lifetime of love into every second.

The days that followed are a blur. Grief and disbelief morphed into guilt. What had we done? The doctors had said might never walk, not would. They had said unlikely to swallow, not would never. Miracles happen all the time – Alex could have recovered, he could have laughed, could have loved, could have lived. “What if?” was the constant whisper in my ear. What if you’d let him live?

Writing has always been my way of making sense of the world. Back then I was a police officer, not an author, but I found I had a burning need to write about what had happened. What if we’d made a different choice? What if Rob and I had disagreed? What if the doctors had been wrong? What if, what if, what if…

I couldn’t have written After the End immediately after Alex died, not only because it was too raw, but because I didn’t know how it ended. As the title suggests, the story is about what happens after a life-changing event, and for us the clock had stopped. I didn’t know then that the world moves on, that it’s possible to laugh again, love again, live again. I didn’t know that Alex’s death would teach me to seize the day, to smile more, to celebrate each fleeting moment.

Writing After the End was a deeply emotional experience. What happens in the book is Max’s and Pip’s story, not mine, and the filter of fiction finally enabled me to grieve. The story broke my heart all over again, but it mended it, too, and I finally made peace with our decision. None of us can predict the future, but we can shape it as it happens. We can choose to live again.

After the End by Clare Mackintosh is published by Little, Brown at £12.99. Buy it at guardianbookshop.com for £11.43