It's a great feeling to complete the year's tax return and discover that you have a nice refund coming to you. Unfortunately, the IRS won't always give you that refund -- and under certain circumstances, the agency can either hold your tax refund temporarily or scrap it altogether. Avoid these situations, or you could get an unpleasant surprise at tax time.

You missed the due date

There is a statute of limitations on claiming your tax refund for a particular year. If you don't file a tax return for a year during which you'd normally get a refund, the IRS certainly won't volunteer to send that refund to you. You can go back and file a return for that year, but if you wait more than three years after the return's filing deadline, you'll lose your refund permanently. For example, if your return is due on April 16, 2018, you have to file it by April 15, 2021 to claim any refund for that tax year.

IRS headquarters in DC

Image source: Getty Images.

You owe taxes from a previous year

Things can get ugly fast when you're in debt to the IRS. Among the various collections measures it has at its disposal, the agency can seize your tax refunds and apply them to your balance due. The good news is that losing your refund this way will at least reduce your tax debt -- but that's not much consolation if you had big plans for the money. So if you owe the IRS back taxes and can't pay, apply for an installment plan or file an offer in compromise immediately so that you won't lose any more tax refunds in the future.

You owe another branch of the government

The Treasury Offset Program uses taxpayers' refunds to pay off their debts to other federal and state government agencies. One of the most common uses of this program is to pay down delinquent student loan debt, although it can also be applied to outstanding child support or state income taxes.

If you're behind on your student loans because you just don't have enough money coming in to make the payments, see if you're eligible to switch to one of the income-based repayment plans. These plans allow you to cap your student loan payment based on a percentage of your income, and they could conceivably reduce your payment to zero. Plus, they lead to automatic forgiveness of any remaining balance after 20 or 25 years.

You're going through a bankruptcy

If you're in the middle of the Chapter 7 or Chapter 13 bankruptcy process, the bankruptcy trustee can petition the court to take some or all of your tax refund and use it to pay off your debts. Once you've completed the bankruptcy process and your debts are fully discharged, the bankruptcy court can't grab any further refunds.

You missed a tax return

If you failed to file a tax return in a prior year, the IRS may hang on to any future refund temporarily until you file the missing return. If you file the return and are found to owe taxes for that year, the agency will likely use the refund it's holding to pay those back taxes. If not, you'll get your refund once the IRS has processed your late return.

The best way to protect your money

Getting large tax refunds is a sign that you're overpaying your taxes in the first place, so the best way to keep your money safe from the IRS is to adjust your W-4 form so that your employer will withhold taxes at a lower rate. You'll lose out on the exciting feeling of getting a big chunk of money all at once, but on the other hand you'll be taking home slightly larger paychecks every month -- and the extra money will be safely out of the IRS's clutches.