If you’re a citizen of Canada, Mexico, or another country and sometimes live and work in the U.S. on a visa, you may be considered a nonresident alien. For tax purposes, the IRS defines a nonresident alien as a non-U.S. citizen who is legally present in the U.S. but either lacks a green card or does not pass the substantial presence test. As a nonresident alien, the IRS requires you to pay income tax only on the money you earn from a U.S. source.

Many nonresident aliens who live and work in the U.S. choose to invest in a 401(k) retirement plan offered by their American employer. However, when it’s time to return to your home country, this can create quite a quandary. Should you leave your funds in the 401(k)? Should you cash it out before you leave the U.S. or wait until you’re back in your home country? Should you roll it over into another account? And how will your 401(k) withdrawals be taxed once you no longer live in the U.S.?

Keep reading to learn how to solve this nonresident 401(k) conundrum.

Cashing Out

When it comes to early retirement account withdrawals, the rules are the same for both U.S.residents and nonresident aliens. According to the IRS, participants in a traditional or Roth 401(k) plan are not allowed to withdraw funds until they reach age 59½ or become permanently unable to work due to disability. If you are younger than 59½, not disabled and choose to cash out the funds from your 401(k), you’ll be subject to a 10% early withdrawal penalty. So, if your 401(k) is worth $15,000 and you decide to liquidate the account, you’ll be required to pay an additional $1,500 in taxes. That means your withdrawal is essentially slashed to $13,500.

To top it off, your entire 401(k) withdrawal will be taxed as income by the U.S. even if you’re back in your home country when you withdraw the funds. Because contributions to traditional 401(k) accounts are made with pretax dollars, this means any withdrawn funds are included in your gross income for the year the distribution is taken. Let’s say your income tax rate is 20% in the year you liquidate your 401(k). This drives the total tax impact up to 30% for that withdrawal (the 10% early withdrawal penalty + the 20% income tax rate).

Therefore, when you withdraw $15,000 from your 401(k), you’ll have to pay a total of $4,500 in taxes, which whittles down the grand total of your take-home amount to $10,500. This is precisely why many financial advisors tell U.S. residents that cashing out their 401(k) before they hit 59½ isn’t the smartest option.

However, a tax expert may offer different advice to a nonresident who is planning to return to his or her home country. If you move back and wait until the next tax year to cash out your 401(k), you will most likely fall into a lower tax bracket since you’ll no longer be working and earning income in the U.S. This could greatly reduce the amount of income tax you’ll have to pay on the 401(k) distribution. Remember: No matter where you live when you cash out, you’ll still have to pay the 10% early withdrawal penalty if you’re younger than 59½. 

Roll It Over

Another way to lower your tax payment on a 401(k) withdrawal is to transfer the funds to another tax-advantaged account such as an individual retirement account (IRA). When you take a direct rollover from your 401(k) to an IRA, you will avoid the 10% early withdrawal penalty. To pull this off, you’ll need to open the IRA first and then fund it with the 401(k). 

Like a 401(k), if you take a distribution from your IRA before you reach age 59½, "you will still incur a 10% tax penalty, but you have more flexibility in terms of exceptions for avoiding the penalty like unreimbursed medical expenses, first-time homebuyer, disability, etc.," says Mark Hebner, founder and president of Index Fund Advisors, Inc., Irvine, Calif., and author of "Index Funds: The 12-Step Recovery Program for Active Investors." 

As one example, you can make a penalty-free early withdrawal from an IRA for qualified higher-education expenses, such as tuition, books, and supplies for enrollment at an eligible institution–plus a specified amount for room and board as determined by your school if you attend at least half-time. The IRS notes that some overseas educational institutions participate in the Department of Education’s Federal Student Aid (FSA) programs. Be sure to check with the school first to see if it is considered an eligible educational institution.

Keep in mind that IRA distributions sent to an address outside of the U.S. are subject to mandatory federal withholding of 10%. However, some financial institutions will allow you to waive this withholding by filing special documents. If you choose to take this route, your distribution will be subject to the treaty rate of your current country. The treaty rate ranges from zero to 30%.

Once you have rolled your 401(k) into an IRA, you may also choose to transfer the IRA funds to a retirement account in your home country. For example, Canadian citizens can roll over their U.S. IRA plans to a Canadian RRSP (Registered Retirement Savings Plan). However, as a Canadian resident, this will result in a withholding tax in addition to the 10% early withdrawal penalty if you have not yet reached the age 59½ threshold. 

Bottom Line

Withdrawals from 401(k)s are taxed the same way for residents and nonresidents. If you’re a nonresident with a 401(k) and are planning to return to your home country, you can cash out the account, roll it over into an IRA, or leave the funds where they are until you turn 59½ and can start taking penalty-free withdrawals. "Although you are allowed to leave your funds in the 401(k) until turning age 59½ or later, the funds would be subject to your employer’s options and fees," says Carlos Dias Jr., wealth manager. It is also important to note that some investment firms are reluctant to have an investment account held by an individual no longer living in the U.S.

Before you make this important decision regarding your 401(k) withdrawals, consider speaking with a financial professional or tax attorney.