If you’ve received a foreclosure notice from the bank, you’re probably pretty stressed. Where will you live? How will this affect your credit? Is there a way out of this nightmare?

You’re certainly not alone in your struggles. About 933,045 U.S. properties were foreclosed on in 2016. The good news is that only about two-thirds of these properties actually result in foreclosures, and you have options to escape with your financial dignity intact.

When being foreclosed on, many homeowners believe the best option is to simply walk away as quickly as possible and start over somewhere new. However, you might end up with severe financial consequences from walking away from your home ignoring the problem, not to mention you’ll be out a place to live.

Instead of taking it lying down, consider your options for escaping the negatives of foreclosures.

  1. Consider Declaring Bankruptcy

A foreclosure notice means that the bank has court-given permission to sell your home to pay off the remainder of the mortgage. However, you can stop their efforts to take your house out from under you by declaring bankruptcy, particularly if you have mounting debts in other places that you can’t resolve on your own.

“Bankruptcy is your best battleground,” says Michael H. Schwartz, a New York attorney specializing in bankruptcy and foreclosure defense. “If you have a home threatened with foreclosure, we can help you stop the banks.”

Bankruptcy isn’t always the best option. If you owe more on the house than it’s worth, for example, it’s often better to let the house go and find other living arrangements. However, if your house doesn’t sell for enough to cover the remaining mortgage, declaring Chapter 7 bankruptcy will allow you to walk away from the house without owing the lender anything.

  1. Defend Yourself Against Creditors

Additionally, Mr. Schwartz warns against creditors and servicing companies that will try to get payments, often in unethical ways. They will often tell you to pay more than you owe so that they can collect a fee.

“These servicing companies have no incentive to help you save your house from foreclosure,” according to Mr. Schwartz. “We don’t play their game because we know the rules. They’ll run you in circles. All the while the clock is ticking and they’re racking up more fees.”

Don’t fall for their scare tactics, and don’t try to negotiate with them or work with them to pay your debts. There are good ways to get out of debt and it’s best to go straight to the source.

  1. Negotiate with Lenders

Speak with your lenders about your situation and see if you can refinance for better interest rates and lower payments.

First, seek the help of a foreclosure counselor who can help you assess your assets and risks and get the best refinancing options for you. They’ll work with your lender to negotiate on your behalf.

“Let your lender know that you’re working with a counselor,” says Jerry Demuth of House Logic. “Not only does it demonstrate your resolve, but…homeowners who receive foreclosure counseling are 1.6 times more likely to avoid losing their homes than those who don’t. Homeowners who receive loan modifications with the help of a counselor also reduce monthly mortgage payments by $454 more than homeowners who receive a modification without the aid of a counselor.”

  1. Look Into Government Programs

If your lender refuses to negotiate with you or they are unable to offer a deal that satisfies your need, consider exploring government programs. The government offers several “Making Home Affordable” programs that allow you to modify your loan or refinance when facing foreclosure. If you qualify for this loan, you’ll undergo a three-month trial period to make sure you can pay your new mortgage amount before it becomes permanent.

There’s also the Freddie Mac Enhanced Relief Refinance Program (also known as FMERR) and the Home Affordable Foreclosure Alternatives programs. The FMERR program, for example, is great for homeowners who have little to no equity in their homes. Through this refinance program, you have the chance to achieve a lower mortgage payment and rebuild some equity that will encourage you to stay in your home.

Foreclosure is a frightening word, but if you have the right people and programs defending you, you can get through it with your head held high.