401k © Alex Belomlinsky, Photodisc, Getty Images

Many of us invest in tax-advantaged retirement accounts such as a 401k or Roth IRA to save as much as we can. But these accounts can create challenges for people who are forced to leave a job or decide to retire before 59 ½.

The government discourages people from dipping into their retirement funds by levying a 10% penalty on withdrawals if you’re younger than 59 ½. However, retirement doesn’t always go as planned, and many people will need to use these early withdrawal options:

Use other assets first

The easiest option is to use your other assets to bridge the gap until you’re 59 ½. Funds from a taxable brokerage account, bonds, CDs, or other investments can be cashed in to fund your expenses until you can withdraw from your retirement accounts with no penalty. This is why it is important to start making passive income before you retire. A home equity line of credit might be a good option if it’s only a short time before you’re 59 ½.

Other options are to work part time or to generate a small income from self-employment to cover some expenses.

Roth contributions

You can take penalty-free withdrawals from a Roth IRA, if they don’t exceed the amount you contributed and the account is at least five years old. But the earnings in the Roth IRA don’t become tax free until you turn 59 ½. And if you take money out, you’ll have reduced its ability to grow. Once you take out the money it can’t be put back in.

Early 401k distribution

If you retire or are fired from your job after you are 55, then you can withdraw from your 401k without having to pay the 10% penalty. But this rule only applies to your current employer’s 401k plan.

If you have a 401k with a previous employer, you still have to pay the 10% penalty if you withdraw from that account before age 59 ½. One simple way to avoid this penalty is to roll over the 401k from your previous employer to your current plan. Also, this exception only applies to your most recent 401k and not IRAs. Some 401k plans do not offer this option, so you will need to verify whether or not you can do this with your plan.

Annuitize your IRA

If your IRA is comfortably large, then 72t distributions might be a good option.

Setting up 72t withdrawals means you’ll take substantially equal periodic payments (SEPP) based on your life expectancy. The withdrawals will have to continue for at least five years or until you reach 59 ½, whichever is longer. If you’re 52, then you’ll have to continue withdrawals until you’re 59 ½. If you’re 58, then you’ll have to keep withdrawing until you’re 63.

The withdrawal math is somewhat complicated, and there are three different ways to calculate your withdrawal amount. You might want to see a tax professional to make sure you do the calculation correctly. If you make a mistake, you’ll be hit with the 10% penalty on the entire amount withdrawn.

Avoid early withdrawals if possible

Generally, it’s a bad idea to take early withdrawals from your retirement accounts. That’s why the IRS discourages it with the 10% penalty.

By withdrawing money early, your retirement portfolio will be much less likely to last for the rest of your life. Investing in both a 401k and Roth IRA is still a great way to save, even if you plan to retire early. However, it’s better to find a way to make things work so you can keep the retirement portfolio for when you’re older than 59 ½.

Click here to become a fan of MSN Money on Facebook

More from U.S. News & World Report: