Bankruptcy is a legal proceeding that occurs when the owner of a business can no longer pay its outstanding debts. It typically follows efforts by the business to raise money by liquidating its assets and/or selling part or all of the company.
The bankruptcy process starts when the business files a petition for bankruptcy. Once underway, it provides the company with some legal protections not otherwise available during attempts to save the company. For example, the judge could prohibit other third parties from commencing legal moves against the debtor company while it negotiates with creditors and shareholders.
Once the bankruptcy process is complete—when the assets have been sold off and creditors repaid as much as possible—all remaining debts are erased.