Whether you’re drowning in debt because of unemployment, medical bills, or just good old-fashioned spending—in 2016, almost 772,000 Americans found themselves in one of those situations—you’ve probably considered declaring personal bankruptcy, an option designed to allow people in financial distress to hit the reset button. But does it work? And should you consider it? Here’s what you need to know.

When should I consider bankruptcy?

Anytime you find yourself with more debt than you can handle, bankruptcy is an option worth exploring. Bruce Weiner, a New York bankruptcy attorney, says that in nearly 40 years of practice he’s found “a good thumbnail is when the amount you owe starts to approach what you make in a year.” (Note: Some debts—like taxes, child support, and mortgages—aren’t usually eligible for bankruptcy relief, so if you owe those, you’ll have to pay them even if you file for bankruptcy.)

The U.S. offers a half-dozen forms of bankruptcy to choose from, each named for the chapter of the law that established it. The most popular for individuals are Chapters 7 and 13.

Chapter 7

Also known as “liquidation” bankruptcy, Chapter 7 is by far the most common form of personal bankruptcy in the United States (versus Chapter 11 for businesses).

After you file your paperwork, the judge appoints a “trustee,” whose job it is to sell (“liquidate”) any assets you have and distribute the proceeds among the people to whom you owe money.

Luckily, this won’t leave you naked and homeless. Part of the trustee’s job is to ensure that you’re left with the resources you need to live and work. Plus, any money you earn from that day forward is yours to keep.

Chapter 13

If you have a steady income, Chapter 13 offers a somewhat gentler solution. Instead of selling your assets, a Chapter 13 trustee works out a legally binding plan for paying back your debts, or a percentage of them, over a fixed time period, usually three to five years.

Along with letting you keep your stuff, in some cases Chapter 13 can apply to common types of debt that Chapter 7 doesn’t cover.

What happens when I file?

Different kinds of personal bankruptcy all share one glorious feature: the “automatic stay.”

The day you file your paperwork, your creditors are legally barred from trying to collect their debts. That means no more lawsuits. No more “Final Demand” on red-trimmed envelopes. No more voicemails demanding you call the sinister “Mr. Peterson” back “immediately.” Instantly, those headaches are gone for good. And soon your debts are also gone—or “discharged,” in legal terms.

What’s the catch?

There’s one great reason not to file for bankruptcy: Your credit score takes a hit. Of course, if you haven’t paid a bill for a year or two, your score may already be in the basement. If not, you can expect a drop of several hundred points. And that black mark stays on your record for eons—a decade for Chapter 7, eight years for Chapter 13.

In many cases, though, declaring bankruptcy will actually leave you with a higher credit score than if you simply allowed your debts to fester. Weiner says that many of his clients are shocked to start receiving offers for credit cards and mortgages only months after filing for bankruptcy.

So, going bankrupt is good?

No. Bankruptcy is unpleasant, and intrusive, and creates an indelible record of a low point in your life.

“Nobody wants to end up here,” says Weiner. But it beats the constant, crushing stress of unpayable debt.

Not only that, but, well, bankruptcy is also fundamentally American. That’s why it’s in the Constitution. The Founding Fathers knew that if this land was going to be a place where citizens could dream big and take risks, they also had to have what Weiner calls “the freedom to fail.”

That freedom is yours to enjoy— if you’re ever unlucky enough to need it.