In an ideal world, your pay would keep going up and up until the day you retire. Don’t count on it: Raises can be harder to come by late in your career, especially when you’re already making a good living. 

Among college-educated workers, pay growth tends to top out at age 40 for women, early 50s for men, according to the salary research site PayScale.

“If you’re in the twilight years of your career and expecting large pay increases, you’ll probably be setting yourself up for disappointment,” says Katie Bardaro, lead economist at PayScale.

While your pay may naturally level off 10 to 20 years from retirement, you probably don’t want it to actually fall. But in some cases, taking a lower-paying job can make financial sense.

Here’s why, plus advice on how low you should be willing to go.

Your job is in serious danger

Once you pass 50, you know that the risk of a layoff looms large. A recent study of workers over 50 by ProPublica and the Urban Institute found that more than half of workers who had seemingly stable full-time jobs at age 50 report being pushed out of at least one job, if not two or three. Returning to the workforce after a late-career layoff almost always goes hand in hand with a pay cut.

When your company or division isn’t doing well, finding a new job before you’re laid off might be your best career move. “If you’re working at a company that’s laying off employees left and right, you need to think about job security,” says Bardaro.

More than half of workers who had seemingly stable full-time jobs at age 50 report being pushed out.

“If you have the opportunity to take a lower-paying job at a company that’s more stable, it may make sense to make the jump.”

You’re moving to your future retirement town

As long as you’re planning to move in retirement, you may want to finish out your career in that place as well.

Depending on where you live and where you’re moving to, you may have take a pay cut to do so, says Michelle Armer, CareerBuilder’s chief people officer. “Salaries are typically related to the cost of living per city,” she points out. 

Case in point: Librarians in the San Francisco Bay Area earn $81,690 a year on average, according to the Bureau of Labor Statistics (BLS), significantly more than the $62,470 average for librarians in Houston. 

You’re searching for better benefits

Out-of-pocket healthcare costs keep rising as you get older. In 2017 55- to 64-year-olds spent an average of $5,777 on health care, including insurance premiums, co-pays, and drug costs, according to BLS’s latest Consumer Expenditure Survey. For 25- to 34-year-olds, that total was $3,163.

That’s why in those years leading up to Medicare eligibility at 65, you may put heavy stock in a comprehensive health plan at work, with a manageable deductible, a wide network of doctors, and favorable formulas for cost-sharing. 

In those years leading up to Medicare eligibility at 65, you may put heavy stock in a comprehensive health plan at work.

It’s no surprise, then, that older workers highly value generous company coverage. In a recent survey from market research firm Clutch, 62% of baby boomers named health insurance the most crucial employee benefit; fewer than half of young workers felt the same way.

So if your current employer offers skimpy medical benefits, taking a lower-paying job at a company with better coverage could be a smart move. 

You’re switching to a new industry

Obviously, some fields pay more than others. “The industry and type of work someone is doing have an impact on the salary, no matter how much experience,” says Armer.

Let’s say you’ve been a nurse practitioner your whole career, but you’ve decided to leave that rigorous field and retrain to become a computer programmer.

While nursing jobs are projected to have rapid job growth, the computer programming industry is expected to lose about 21,300 jobs between 2016 and 2026, according to the BLS. The average pay for a programmer is 20% less than what nurse practitioners make.

You can make more money in the long run

When you’re toying with taking a lower-paying job, think about your long-term earnings potential, not just your salary now. Perhaps you’ve topped out in your current job and the one you’ve been offered has more upside.

“One thing you really want to focus on is how much you can make over time at that company or in that position,” says Bardaro. “If you’d be taking a pay cut you need to ask yourself: ‘Is this a job where I can get rewarded with bigger pay increases later on?’”

How low should you go?

Even if you have good reasons to accept a pay cut, you should do so within reason. Ask yourself these three questions before you take a job offer:

Can you afford it? Even at a lower salary, can you still pay down your debts, fund your retirement plans, and achieve other financial goals? If the answer is yes, you’re on solid ground. “I can’t say that someone should never take a pay cut that’s below 3% or 5% or another percentage, since it really depends on the person’s financial situation,” says Bardaro.

Is your lower salary near what the market pays? Even if you’re willing to earn less, you don’t want to sell yourself short. Knowing what a typical salary is for someone with your level of experience gives you a crucial point of reference for judging job offers.

Knowing what a typical salary is for someone with your level of experience gives you a crucial point of reference.

There are a number of online resources you can use to determine your market value in a new place or field. PayScale’s Salary Calculator will provide a rough estimate based on your occupation, location, and years of experience. You can also use Glassdoor to find salaries reported by real employees.

Are you negotiating as well as you can? “You want to be very careful about placing a floor on what you’re willing to accept, because it can vary significantly based on your priorities and the other aspects of the job offer,” says Bardaro. When reviewing any offer, look at vacation time, teleworking options, and other perks too. 

“You should always negotiate,” Bardaro says. “If an employer is making you an offer, the company wants you, which gives you leverage.”