Three years ago, Ada Calhoun couldn’t sleep. The 41-year-old writer stared at her ceiling wondering why her hard-won accomplishments had left her feeling exhausted, anxious and wanting. She had written two well-regarded books and a long list of magazine articles. She was married and her son had just been accepted to a great public middle school. From the outside, she knew, her life looked good.

Yet she was kept awake by freelancing assignments that had fallen through, corporate job opportunities that had evaporated and her family’s looming credit card debt. When she looked in the mirror and saw wrinkles and a wider midsection, she asked herself “whose body is this?” After decades of doing everything right, growing up at a time when women were told they could do everything, this was not how life was supposed to go.

Was this a midlife crisis?

They only happened to men, as the mythology would have it, and involved great dramatic escapades. “There has yet to be a blockbuster movie centered on a woman staring out her car windshield and sighing,” as Calhoun would later write.

When an editor at Oprah.com asked her to write about what was going on with Generation X women at this stage of their lives, Calhoun had not expected to find so many other middle-class women of her generation feeling the same angst.

“Maybe it’s just me and my editor’s friends,” she thought.

Her article went viral, leading to her latest book, “Why We Can’t Sleep, Women’s New Midlife Crisis.” She dedicates the book to the middle-aged women of America with a validating conclusion: You’re not imagining it, and it’s not just you.

Midlife for Gen-X women is particularly hard, Calhoun said in a telephone conversation, describing their lives in one breathless sentence:

“A typical Gen-X woman in the year 2020 is working an intense, full-time job or is underemployed and frustrated about it, and is caregiving for some combination of aging parents or other relatives and children in their young or teenage years, or dealing with fertility issues while going through perimenopause and is not really being supported by her doctor because a lot of doctors don’t study menopause and her phone is blowing up with reminders and breaking news and demands from her boss and that means she’s probably very tired and always on edge and alert and doesn’t get a lot of downtime and she’s been told she is so lucky because men do more at home and there’s no World War going on so she feels anxious and tired and ashamed that she feels that way.”

Gen-X arrived at midlife after a childhood of high divorce rates, rising crime and MTV, through adulthood and the imbalance of work and family, Calhoun observed in her book, putting this quiet crisis in context. Women have told her reading the book has “removed this layer of shame” they felt and the sense they had “done something wrong,” while everyone else had life figured out.

The cohort was born between 1965 and 1980, according to the Pew Research Center, but the dates are debated, with some putting the last year at 1984. Calhoun describes it as the “Jan Brady of generations,” referring to the middle daughter in“The Brady Bunch” sitcom. It is also smaller in size than the baby boomer and millennial generations, a position that may explain why Gen-X women feel isolated in what is already a confusing phase of life, perimenopause, or the transition to menopause signaled by irregular periods and night sweats.

“I go to my stupid annual exam and get my Pap smear,” Calhoun said. Still, she had not even heard the word perimenopause until two years ago.

Women are embarrassed to talk about “closing up shop as a sexual being,” Calhoun said, so they do not talk about what really happens before periods stop for good. “It’s up and down and chaotic and strange,” she said. The hormonal changes can last for years and cause mood swings, weight gain, sleeplessness, painful intercourse, breast pain and cysts, and other symptoms.

Gen-X women are not the first to experience perimenopause, of course. But Calhoun, now 43, makes the case that they are going through it with unique circumstances.

“It’s just so different,” Calhoun said. Gen-X women typically waited to establish their careers before having children, so they experience the demands of aging parents, dependent children, stressful careers and the hormonal swings all at once.

They also have unrealistic expectations for adulthood, epitomized by the commercial for Enjoli perfume they saw as children that told them they could bring home the bacon, fry it up in a pan and still, after a long day in heels and reading to the kids, never let the husband forget he’s a man.

The message was “like a drug that a lot of people took and it plays into an inflated expectation of what we should do as women,” Calhoun said.

High expectations without a cultural and economic structure to help achieve them produces a “toxic combination.” A key strategy for coping with this pressure is to “lower expectations,” Calhoun said. In her book, she also reminds women the game is rigged.

“If we feel that things are tougher now, it could mean only that we’re paying more attention,” she said. “This is a bumpy stretch in life. We should not expect to feel fine.”

Calhoun offers other suggestions for easing the bumps.

Besides finding a gynecologist with expertise in menopause — there is a searchable database of North American Menopause Society’s Certified Menopause Practitioners — she suggests starting a club with other women for support. Calhoun meets with fellow writers. Other women have started book clubs.

At her website, ­AdaCalhoun.com, she has compiled a Why-You-Can’t-Sleep playlist topped with Salt-N-Pepa’s “None of Your Business” and the Go-Go’s “Girl of 100 Lists.”

She has found it helpful to learn from women who have already gone through menopause, who describe feeling more solid and peaceful. Women can “look forward to that. When everything is not in flux physically,” she said.

There is power, too. Menopausal killer whales lead their pod to food, she tells readers, referring to Darcey Steinke’s book, “Flash Count Diary: Menopause and the Vindication of Natural Life.”

When Calhoun was a teenager, she had a postcard over her bed with images of a mushroom cloud, war and the words “Why We Can’t Sleep.” As she researched her book and discovered most of her peers had trouble sleeping, she thought of what the words mean to her decades later.

“I liked that image of women, all around America just staring at the ceiling at 4 a.m. and whatever is in her head, being in the book.”

Learning that she was not alone, and not imagining what was going on with her body and life, has given Calhoun some peace of mind.

“I used to lie there,” she said. “What is going on? Why am I so freaked out? Why am I so anxious? Why am I broke?”

She has stopped asking those questions.

“I feel a lot more peaceful,” she said. “A lot less perplexed.”

Now when she wakes up, she can go back to sleep.