Consider a pair of twins who grow up together, have the same talents and education, nurture the same desire to raise a family, and embrace the same ambitions for their career. But in adulthood, one twin consistently earns less than the other, has a spottier work record and gets stuck further down the career ladder. That twin reaches retirement age with a smaller cache of savings, less guaranteed income and a real risk of running out of money later in life.

The difference between the siblings? Gender. In this parable of fraternal twins, the female twin earns 79 cents for every dollar the male twin earns. She takes more breaks from the workforce to care for children and other family members, and consequently has less access to employer-sponsored savings plans, such as a 401(k). She also has a smaller Social Security benefit, based on her reduced earnings. And here’s the real kicker: Because she has a longer life expectancy than her twin (a 65-year-old woman can expect to live to 85, on average, compared with 83 for a 65-year-old man), she will have to stretch her resources that much further.

Like all parables, this one is based in fact: the gender gap that has long put women at an economic disadvantage. The good news is that the gap is closing. Women now graduate from college in higher numbers than men and hold more master’s degrees. They represent almost two-thirds of the workforce, according to a report by U.S. Bancorp. The pay gap narrows considerably (often to the point of disappearing) for men and women with similar educational backgrounds and jobs. And to a large extent, differences in income and economic circumstances reflect women’s decisions about which jobs to hold and their choices (made with their families) about who stays home to care for kids or elderly relatives.

But those circumstances are no less real, and the decisions women make about managing their money, staying in the workforce, and saving and planning for retirement can make all the difference. No one can turn the ship around alone. But whatever your stage of life, you can chart a course to financial security. (In the interest of equity, we’ll point out that the advice that follows can apply to men, too.)

1. Stay in the Game

Erin Williams of Ossining, N.Y., planned to return to her job as a clinical trial coordinator after the birth of her daughter, Lucy. But once Lucy arrived, Williams realized she would clear only $100 a week after paying for child care. “I wanted to be with her. It wasn’t worth it to work full-time,” she says. Williams and her husband, Kyle Fortin, agreed that she would stay home and earn money through writing and other projects. A year and a half later, Williams is cofounder, with blogger Jordan Reid, of GlamCamp.co, an online store featuring original work by women artists, and she writes a blog, Goosecamp.co. She and Reid recently signed a deal with Penguin Random House for a book about pregnancy.

Williams, 33, has been able to arrange her schedule around Lucy’s by taking her career in a new direction. For other women, however, child care or caregiving can lead to career atrophy. Rather than let that happen, consider working part-time, says Catherine Collinson, president of the TransAmerica Center for Retirement Studies. “Keeping your foot in the door makes it that much easier to reenter the workforce full-time when you’re ready.”

Negotiating for fewer hours is easiest if you’re already a valued employee, says Collinson. But if a part-time arrangement isn’t in the cards, stay marketable by taking classes at a local college, volunteering and networking. That’s what Evelyn Ross did after being a stay-at-home mom. Ross, who lives in Silver Spring, Md., took business classes, worked on a local mayoral campaign and, with the help of connected friends, landed a job in the mayor’s office after her candidate won. “Relationships pay off,” she says.

2. Be Involved in the Finances

Ross may have been savvy about how to reenter the workforce, which coincided with her divorce, but she describes herself as “ignorant” about finances. “Oh, God, I didn’t know anything. Money scared me,” she says. No surprise there. Women control 80% of all household spending, but when it comes to investing and other financial decisions, “usually it’s the man who steps up,” says Angie O’Leary, senior vice president at US Bank. Ceding financial responsibilities can be disastrous for wives, especially because they are likely to outlive their spouses. “For the most part, all this wealth is going to them,” says O’Leary. “They really need to understand what to do with it.” (Men and women often speak different languages when it comes to money.)

One way to close the knowledge gap is simply to communicate with your spouse. A 2015 Fidelity survey on couples and their finances showed that more than 40% of couples didn’t even know how much each spouse earned, and 36% disagreed on their joint investable assets. Cluing each other in and deciding on goals together can make both spouses financially more secure and avoid leaving one spouse in the dark after a death or divorce.

Another strategy is to consult a financial planner. If you’re married, go together—but whether you’re married or single, find a planner you’re comfortable with. A recent study by the Insured Retirement Institute showed that women find it much more important than men to work with a planner who listens and is responsive. Not surprisingly, they also seek ad­visers who address them and not just their spouse. For Ross, discovering a sympathetic adviser in Marguerita Cheng, a certified financial planner in the Washington, D.C., metro area, was “a blessing,” she says. “We would sit at my kitchen table and discuss my finances over tea or coffee. If not for Rita, I don’t know where I’d be.”

Patricia Glosner saved enough to retire at age 48. Anna Knott

3. Save, Save, Save

Patricia Glosner says her attitudes toward money were shaped by her parents’ separation, which left her stay-at-home mother with few resources of her own. “One of my goals when I went into the workforce was to always be financially secure and financially independent,” says Glosner, 48, who lives in Chicago. A clinical pharmacist with Pfizer, she always contributed the maximum to her 401(k) plan, as did her husband, Scott, who also works for Pfizer. They usually maxed out their plans by September or October; after that, they continued to make after-tax contributions. They also contributed to 529 college-savings plans for their two children.

As a result, Glosner has achieved her goal of retiring early. She may go back to work at some point, possibly in the field of health and wellness. In the meantime, she has taken over management of the household finances and has become more involved in making decisions about the couple’s investment portfolio. In the past, Scott managed the money, and taking over that responsibility “was an eye-opener,” Patricia says. “I really got a clear idea of what we were spending.” That’s becoming more common among women her age and younger, says Glosner’s adviser, Pamela Wise, a certified financial planner with Merrill Lynch Wealth Management. Because many of them have been high earners, says Wise, “this generation of women want a seat at the table.”

Whether you plan to retire at 50 or 70, there’s a good chance you’ll live into your nineties, so you need to save accordingly, by contributing the maximum to your 401(k) or other workplace plan (see Retire Rich). If you’re self-employed, as many women are, or you have a side business, as many women do, you can save even more in a tax-advantaged plan. With a SEP-IRA, for example, you can put aside up to $53,000 a year.

And because you can look forward to such a long time in retirement, you may need to invest a larger percentage of your portfolio in stocks than your husband does, says Kevin Meehan, a certified financial planner in Itasca, Ill. (see The Secrets of Women Investors). If your investments are too conservative, you risk running out of money before you run out of breath. Plus, women investors “may need stocks not just to benefit from potential growth but also to outpace inflation,” Meehan says.

4. Cover Your Bases

You and your spouse should have a will. Otherwise, the courts will divide up your assets based on your state’s intestacy laws. The surviving spouse, likely the woman, may receive only half of the estate, with the rest divided among your children (or if your spouse was married before, any children from that marriage, which could get really messy).

You both also need end-of-life documents. A durable power of attorney allows a family member or designated agent to make financial decisions and transactions, such as paying the bills, on your behalf if you become incapacitated. A durable power of attorney for health care gives someone the authority to make medical decisions. A living will specifies the kind of end-of-life medical treatment you want.

Many married couples give each other power of attorney for finances and health care. If you outlive your husband, be sure to update these documents so that someone else you trust can assume those responsibilities.

It’s critical to check the beneficiary designations on your retirement plans, IRAs and insurance policies to make sure they’re up-to-date, and ask your spouse to do the same. In most cases, beneficiary designations take precedence over the will, so it’s important to review them after a major life change, such as marriage, divorce or death of a spouse. You don’t want the assets going to your mother-in-law, your spouse’s ex-wife or children from a previous marriage unless you have agreed to such an arrangement.

5. Set Retirement Goals

Couples nearing retirement will have to make key decisions about where and how to live, as well as how to ensure that any pension or annuity payments go to the survivor—usually the wife—and how to maximize Social Security for both of you when one spouse—usually the husband—is the high earner.

Kathryn Siebert's home is part of her retirement strategy. Katie Baldwin

For many women, working longer is often the best solution to a shortfall, not only because it bolsters your savings but also because it helps you delay taking Social Security. You’ll get an 8% boost in benefits for every year you delay past full retirement age, until age 70. And Social Security benefits adjust with inflation. Trying to buy an annuity with similar benefits in today’s marketplace would be “extremely expensive,” says Diane Oakley, executive director of the National Institute on Retirement Security.

If you’re planning to work longer anyway, try to switch to a job with a pension, advises Oakley. Rare in the private sector, traditional defined-benefit plans are still common at jobs in health care, education and public administration, and many vest after five years. Adding that income to other resources will go a lot further than trying to catch up on savings when you’re close to retirement, says Oakley.

Your house is also a great resource if you can tap the equity through a reverse mortgage (see Reverse Mortgages Get a Makeover) or continue to live there after paying off the mortgage. Kathryn Siebert, 59, has a more creative idea. She loves her job at a nonprofit in Portland, Ore., and has no plans to retire soon, but she also has to repair her finances after a divorce. She kept the family home—a Craftsman-style house—and, for now, rents out a room to help cover monthly costs. When she retires, she will either sell the house and reap the considerable profit or invite her sons, Emil, 26, and Austin, 22, to move in. “My boys can’t afford to live in this town, but they could afford to live in the house and take over the mortgage while I travel the world,” says Siebert. Ultimately, she’d like to come back home and enjoy a multigenerational household, as she did growing up.

6. Anticipate Health Costs

Health care costs can jeopardize your retirement security. Fidelity Investments estimates that a 65-year-old couple who retired in 2015 will spend $245,000 on health care throughout retirement. That’s up 29% since 2005, reflecting rising medical costs and longer life expectancies.

If you’ve been saving for retirement, you’ve already put aside funds for health care costs. And if you’re healthy, you may not need that much. Still, as you approach retirement, it’s a good idea to calculate premiums and deductibles for Medicare Part B (which covers doctor visits and outpatient care), along with supplemental insurance, such as Part D for prescription drugs and a medigap policy to cover out-of-pocket expenses.

If you have an eligible high-deductible health insurance policy, you can open a health savings account and put aside money to cover your out-of-pocket health care costs. An HSA gives you a triple tax break: contributions are tax-deductible (or pretax if you make them through your employer), the money grows tax-deferred, and it can be used tax-free for medical expenses. You can let the account grow until you retire, when you can use tax-free withdrawals to pay the premiums for Medicare parts B and D, Medicare Advantage or other health costs. Once you turn 65, you can even use the money for non-medical expenses without paying a 20% penalty, but you’ll pay taxes on the withdrawals.

Because women live longer, they are more likely to spend time in an assisted-living residence or require home care. Long-term-care insurance can help cover the costs, but premiums are pricey, especially for women. If you’re married, you can reduce premiums by purchasing a shared-benefit policy that provides a pool of benefits both spouses can use.

Another option is a hybrid policy that combines long-term-care coverage with life insurance. That’s what Rose Swanger, a certified financial planner in Knoxville, Tenn., purchased after her husband, Stephen, was diagnosed with atypical Parkinson’s disease at age 49. Stephen’s illness makes him ineligible to buy his own policy, but if Rose dies first, he’ll receive a lump-sum payment that he can use for medical expenses. If Rose outlives her husband, she’ll use the coverage for her own long-term care. “We have three boys,” she says, “and we want them to chase their dreams and not be burdened by caring for us.”