Robin Williams’ widow, Susan Schneider, details the final months of the actor’s life in a wrenching personal essay titled “The Terrorist Inside My Husband’s Brain,” published in the medical journal Neurology.

Schneider, Williams’ third wife, writes about her late husband’s struggle with Lewy body dementia, misdiagnosed as Parkinson’s disease two months before his death, which ultimately led to his suicide in August 2014.

“It felt like he was drowning in his symptoms, and I was drowning along with him,” she says.

The symptoms included impaired thinking, memory loss, digestive problems, insomnia, paranoia, and anxiety.

“Robin was growing weary,” she writes. “The parkinsonian mask was ever present and his voice was weakened. His left hand tremor was continuous now and he had a slow, shuffling gait. He hated that he could not find the words he wanted in conversations. He would thrash at night and still had terrible insomnia. At times, he would find himself stuck in a frozen stance, unable to move, and frustrated when he came out of it. He was beginning to have trouble with visual and spatial abilities in the way of judging distance and depth. His loss of basic reasoning just added to his growing confusion.”

Schneider chronicles her husband’s 10-month struggle to discover the root of his neurological and physiological problems.

“Robin was losing his mind and he was aware of it,” Schneider writes. “Can you imagine the pain he felt as he experienced himself disintegrating? And not from something he would ever know the name of, or understand?”

Schneider notes that his conditions were so severe that the “Good Will Hunting” star said he wanted to “reboot” his brain.

“He kept saying, ‘I just want to reboot my brain.’ Doctor appointments, testing, and psychiatry kept us in perpetual motion. Countless blood tests, urine tests, plus rechecks of cortisol levels and lymph nodes,” she recalled. “A brain scan was done, looking for a possible tumor on his pituitary gland, and his cardiologist rechecked his heart. Everything came back negative, except for high cortisol levels. We wanted to be happy about all the negative test results, but Robin and I both had a deep sense that something was terribly wrong.”

Schneider recalls that the actor had trouble “remembering just one line” while filming “Night at the Museum 3.”

“In early May, the movie wrapped and he came home from Vancouver — like a 747 airplane coming in with no landing gear,” Schneider writes. “I have since learned that people with LBD who are highly intelligent may appear to be okay for longer initially, but then, it is as though the dam suddenly breaks and they cannot hold it back anymore. In Robin’s case, on top of being a genius, he was a Julliard-trained actor. I will never know the true depth of his suffering, nor just how hard he was fighting. But from where I stood, I saw the bravest man in the world playing the hardest role of his life.”

The couple had been married for three years when Williams hanged himself at their home in Tiburon, Calif., on Aug. 11, 2014. The autopsy results revealed that he died from asphyxiation and suffered from Lewy body dementia, caused by protein deposits in the brain.