If you spent most of your adult life budgeting around a steady paycheck, a departure from the workforce, by choice or circumstance, poses a new challenge: What funds will you use to meet expenses? The answer, which might vary from one year to the next, will inevitably affect your tax bill. And that, in turn, could drastically impact your standard of living.

Tax planning, which is always a concern, becomes even more important during the years between active employment and retirement. Depending on when you leave your job, that could take a decade or longer. Which assets you draw down first and how you coordinate the various moving parts will determine how much you have to live on each year and what goes to Uncle Sam.

You have greatest control over your tax liability between the time you leave your job and your 70th birthday. This presents some unique financial opportunities.

What’s so magical about 70? That’s the age at which most people become eligible for the maximum Social Security benefit, up to 85 percent of which is treated as taxable income. Plus, if you set up and funded a traditional IRA (as opposed to a Roth) – either through annual contributions or the rollover of a 401(k) – you must take yearly minimum distributions, starting at age 70 1/2.

You have until April 1 of the year after you turn 70 1/2 to take the first required minimum distribution, as it’s called. Following that, you must take a payout by December 31 of each year for the rest of your life.

Together, these required withdrawals and Social Security may lead to a bigger tax bill during your golden years than you ever imagined. “What’s said about taxes being lower when you retire is absolutely not true if you’ve been a good saver,” says Claudia Hill, owner of TaxMam, a tax services firm in Cupertino, California. Before you start taking Social Security, pensions or mandatory IRA withdrawals is an ideal time to take advantage of low tax rates that may not be available to you later on.

During the years leading up to retirement, or separation from service, Ty A. Bernicke, a financial planner in Altoona, Wisconsin, encourages clients to “diversify their tax planning” by dividing assets into three different buckets: taxable accounts; tax-deferred accounts, such as traditional IRAs and 401(k)s; and Roths. The sooner you get started with this strategy, the more flexibility you will have later, he and other experts say. Depending on your situation, here are strategies to consider – separately or in combination with one another.

You own stocks in taxable accounts. Let’s say you applied a buy-and-hold approach during the nine-year bull market and want to skim off some of your profits. It may be possible to do that without paying any tax. How?

 First, some background (or review). When you sell an asset such as stock, you owe capital gains tax on the difference between the sale price and what you paid for it – your cost basis. Currently the top rate on long-term capital gains (assets held more than a year) is 20 percent, plus a 3.8 percent surcharge for people whose modified adjusted gross income is more than $250,000 per couple ($200,000 for individuals). But it’s possible for people at lower income levels to harvest gains without paying any capital gains tax. The same rule applies to so-called “qualified dividends,” which are taxed at capital gains rates, rather than as ordinary income.

As you can see from the table below, married couples can have taxable income of up to $77,200 and pay no tax on their qualified dividends or long-term capital gains. (The cap is $38,600 for singles and $51,700 for heads of households.)

2018 TAX RATES FOR QUALIFIED DIVIDENDS AND LONGTERM CAPITAL GAINS (Based on Taxable Income)

SingleHead of HouseholdMarried Filing Jointly
0%Up to $38,600Up to $51,700Up to $77,200
15%Up to $425,800Up to $452,400Up to $479,000
20%>$425,800>$452,400>$479,000
Note: A 3.8% surcharge applies for people whose modified adjusted gross income is more than $250,000 per couple ($200,000 for individuals).

So you might ask, “How much capital gain can I harvest from stock sales (plus qualified dividends) and stay within this 0 percent bracket?”

Two things make the calculation a bit tricky. One is that, in figuring the “taxable income” for purposes of using the table above, net capital gains (long-term gains minus long-term losses) get added to ordinary income. Ordinary income might include: earnings from freelance work, non-qualifying dividends and withdrawals from traditional retirement accounts. Most interest (for example, from CDs, savings accounts and U.S. savings bonds) is also taxed as ordinary income.

The other issue one must consider is that income adjustments (see lines 23 to 37 of your most recent tax return) and deductions (line 40), which reduce your taxable income, can be applied only against ordinary income – not against capital gain. So it behooves you to take enough ordinary income to absorb whatever adjustments and deductions you anticipate; otherwise you will have wasted these tax freebies.

Here’s how to roughly figure out how much capital gain and ordinary income you can take in a given year while paying no federal taxes. This calculation, done on the back of an envelope, assumes you will take the maximum long-term capital gain listed in the table above:

A. Tally up your adjustments. Again, refer to last year’s tax return. Unless something has changed in your financial life, assume they will remain the same.

B. Figure your deductions. The choice each year is whether to take what’s called the standard deduction or to itemize, meaning that you list each deduction to which you are entitled. As a result of the tax law passed last December, most people are likely to take the standard deduction. That deduction is $12,000 for individuals and $24,000 for married couples filing jointly. People older than 65 can add an extra $1,300 per person for married couples filing jointly, or $1,600 if they are unmarried.

C. Total your ordinary income. It should not be more than the sum of A + B. (See suggestions below about potential sources of additional ordinary income to make the most of your tax freebies.)

D. Add up your qualified dividends and long-term capital gains. They should not exceed the amount in the table above, which, based on your situation, allows you to pay zero federal tax.

You can vary all of these amounts. But to achieve zero federal tax on the capital gain, they must fit together in the following equation:

C – (A + B) + D = $77,200 ($38,600 for singles and $51,700 for heads of households)

Of course, financial planners and tax advisers rely on software to run the numbers. At my request, Hill did that for a 62-year-old married couple who file jointly; take the standard deduction of $24,000; and have one adjustment – a $7,900 contribution to a health savings account (more about these below). To soak up their total adjustments and deductions of $31,900 ($24,000 plus $7,900), they withdraw an equal amount from a traditional IRA. Their total qualified dividends and capital gains are $77,200, most of that reflecting gain on low-basis stock they have been holding for more than a decade.

This strategy gives the couple total income of $109,100, and, according to Hill’s calculation using the BNA Fifty-State Planner software, they won’t owe any federal tax. But, she notes, if they live in California, where she practices, they would owe state tax of $3,535 (assuming they take a state standard deduction of $8,472).

Hill ran some variations on the theme to show how it would affect this couple’s taxes. The key thing to keep in mind is that “all ordinary income needs to be factored into the picture as you work toward the magic number of zero taxes,” she notes.

For instance, if the couple had $10,000 more of ordinary income ($41,900, instead of $31,900), they would need to take $10,000 less of capital gains ($67,200 instead of $77,200) in order to work with the equation above. And though they would still not owe any capital gains tax, they would owe ordinary income tax – on the $10,000 worth of ordinary income not offset by their adjustments and deductions. This would be taxed at the federal 10 percent rate, so would cost them an extra $1,000 in tax. (To help with your own back-of-the-envelope calculations, you can check the 2018 tax rate schedules which download here as a PDF.)

If, instead, the couple took an additional $10,000 worth of capital gains without reducing the amount of their ordinary income, they would pay tax on this excess at the 15 percent rate (as reflected on the table above). This would cost them $1,500 in federal tax, and an additional $1,000 in California state tax.

You have saved vigilantly in tax-deferred retirement accounts. Though IRA owners are not required to start taking distributions from traditional retirement accounts until age 70 1/2, if you have plenty of money in one of those accounts, you might want to take out some of these funds sooner. (Note: There’s generally a 10 percent penalty for doing that before age 59 1/2.) Once you no longer have a steady source of income, these withdrawals can be extremely tax-efficient, Hill notes. You can offset the distributions with adjustments and deductions that would otherwise be wasted, and thereby reduce the amount that is subject to tax.

Let’s say you don’t need the extra cash right now. In that case, consider converting some of the funds to a Roth. In this maneuver you roll over money from a pretax IRA into a Roth account. You incur tax that year, at ordinary income rates, on the amount that you convert. But here, too, you can use adjustments and deductions to reduce how much you owe. Under the 2018 tax rate schedules, a married couple can have taxable income (meaning after all adjustments and deductions) of up to $77,400 and still fall within the 12 percent tax bracket. (Note: Don’t confuse these tax brackets, for ordinary income, with those for capital gains included in the table above.)

The payoff of doing a Roth conversion is that, subject to certain restrictions, there’s no income tax on distributions – whether by you or your heirs. In other words, all future growth takes place inside a permanently tax-free wrapper. So if the investments explode in value (and/or tax rates rise later), you will have paid off the tax bill for whatever amount you converted at a bargain rate.

Another advantage of a Roth is that you’re not required to take yearly minimum distributions once you reach age 70 1/2, though of course the money is there if you need it. The tax-free compounding that results is “the big bang of the Roth,” says Guerdon T. Ely, a financial planner in Chico, California.

A 67-year-old law firm partner who recently consulted Ely had IRAs worth $5 million, and saw his annual income drop from several hundred thousand dollars to practically nothing when he retired last year. Ely suggested that he take advantage of his comparatively low tax bracket to convert $100,000 during each of the next three years (before he turns 70 1/2). The lawyer doesn’t expect to ever need that money, and when it eventually goes to his kids, their withdrawals will be tax-free.

As a rule of thumb, don’t convert money that you will be taking out within 15 years, Ely advises. “You’re just accelerating the taxes.”

You plan to freelance. Part-time work can ease your transition from a staff job, reduce how much you must take out of savings and enable you to reap several tax benefits. By taking a home office deduction, assuming you qualify, you can reduce your profits – and the amount that will be taxed.

Having this “earned income,” as it’s called, also enables you to subtract a couple of expenses from the total of all income that’s subject to tax. These “adjustments” include the cost of health insurance for yourself and family members, provided it is not more than your profits from freelance work. You can also sock away money for the future by making contributions to a retirement account – ideally a non-deductible Roth IRA.

For 2018 the limit on non-deductible Roth contributions is $5,500, plus an extra $1,000 for people who are 50 or older.

If you are single and earn more than $120,000 this year (or $186,000 as a couple), you must go through an extra gyration: First put the money into a traditional IRA, and then immediately convert it to a Roth. This “backdoor” approach was blessed by Congress when it passed the December tax overhaul.

You can afford to postpone Social Security. There’s been a lot of ink spilled on when is the best time to start collecting: at 62 (when you first become eligible); at “full retirement age” (66 for most people); or at 70. A leading book on the subject is Get What’s Yours: The Secrets to Maxing Out Your Social Security, by Laurence J. Kotlikoff, Philip Moeller and Paul Solman. The authors conclude that most people are better off financially waiting until 70, since the benefit (and the cost-of-living adjustment applied to it) will be significantly higher by then.

Yet statistics show that only 1 to 3 percent of the population waits, a tendency that financial advisers confirm anecdotally. Many clients are more inclined to take Social Security, rather than withdraw money from their own savings, says Jim Blankenship, a financial planner in New Berlin, Illinois and author most recently of Social Security for the Suddenly Single: Social Security Retirement and Survivor Benefits for Divorcees. “You can throw numbers at people all day long and it may not make a bit of difference to them.”

 Before you claim early, do some homework. First read one of these books with an eye toward your own situation. Meanwhile, you’ll want to set up an account on my Social Security (or sign on to your existing one) and download your Social Security statement. It will show you the difference between the benefits at the various ages. Then consider whether you can use any of the strategies above to delay Social Security.

I went one step further, using software to look at my own situation. For this purpose, I chose MaxiFi, which is the brainchild of author and Boston University economics professor Laurence J. Kotlikoff. It’s an easy-to-use, Web-based system that can help you make other informed financial decisions. It showed that, assuming my husband and I both lived to be 100, we stood to collect about $115,000 more if we both waited until age 70 to collect.

Though this is certainly nothing to sneeze at, waiting until 70 to collect while you implement the tax strategies described above could yield an even greater financial payoff.

You’re too young for Medicare. For many people, the biggest financial burden of losing a steady paycheck is shouldering a greater portion of their healthcare costs until they become eligible for Medicare, at age 65. Under the Affordable Care Act, anyone no longer covered by an employer’s health plan can purchase insurance through state- or federally run exchanges. The cost varies depending where you live, but it tends to be breathtakingly pricey.

To help offset the expense, federal law currently offers a premium tax credit. It is based on the cost of insurance, where you live, the number of people in your family and your income. To get a credit, your income must not exceed 400 percent of the federal poverty line. In 2017 the limit was $64,080 for a family of two and $97,200 for a family of four, according to the IRS website. Though the premium tax credit survived the December tax-law changes, the IRS has not updated either these numbers for 2018 or an “Interactive Tax Assistant” that consumers could use to determine whether they were eligible.

Helping clients position themselves for the tax credit is a key part of planning for folks who have recently left their jobs, Bernicke says. For example, if a couple needs $100,000 to meet current expenses and they withdrew the entire sum from their tax-deferred bucket, this would disqualify them for the premium tax credit. If they have a Roth IRA, he encourages them to take some of what they need from that account instead.

Another tax-wise strategy during those pre-Medicare years is to fund a health savings account, Hill notes. These accounts, which function like a healthcare IRA, allow you to sock away pretax dollars and withdraw them tax-free to pay for health and dental expenses not covered by insurance. To qualify, you must be enrolled in a high-deductible health plan, which for 2018 is defined as one with “an annual deductible that is not less than $1,350 for self-only coverage, or $2,700 for family coverage, and the annual out-of-pocket expenses (deductibles, co-payments, and other amounts, but not premiums) do not exceed $6,650 for self-only coverage, or $13,300 for family coverage.” (Medicare doesn’t qualify.)

The contribution limits this year are $6,900 for family coverage ($3,450 for individuals), with an extra $1,000 allowed if the account holder is 55 or older.

Though these funds can be invested tax-free, it’s also tax-efficient for people in their 50s and 60s to use the money right away to pay for unreimbursed medical expenses, Hill says. This option is especially attractive now that, as a result of the tax overhaul, fewer people will choose to itemize. Though you can deduct unreimbursed expenses (for yourself, your spouse and your dependents) for 2018 if they exceed 7.5 percent of adjusted gross income, you have to itemize for this deduction to do you any good. In contrast, money contributed to a health savings account gets subtracted when figuring your taxable income. So this is another way of paying for healthcare with pretax dollars.

These last two strategies suggest that there is one more reason to diversify your tax situation as well as your portfolio: to protect you against the unknown. The recent tax overhaul is a stark reminder that tax rules change. The new $10,000 cap that it imposed on state and local property taxes, for example, has wreaked havoc with the finances of many households: For decades this deduction was crucial to figuring out how much one could afford to spend on a home. With taxes, as with so much else, there’s little certainty about what’s ahead.

Deborah L. Jacobs, a lawyer and journalist, is the author of Estate Planning Smarts: A Practical, User-Friendly, Action-Oriented Guide. A free update to the book, reflecting the recent tax overhaul, is available for download on the book’s website. Follow Deborah on Twitter at @djworking and join her on Facebook here. You can subscribe to future blog posts by using the sign-up box on the homepage of her author’s website.

RELATED POSTS

How to Make an IRA Last Longer

How to Find Purpose and Meaning Without a Job

To Sell, or Not to Sell (Your House)

MORE BY DEBORAH JACOBS