Technically, bankruptcy is a discharge of debts and financial obligations. If there are funds available, there may be a fractional payment of the nominal value of a debt (what you hear as "pennies on the dollar" in the financial press).
What's also literally happening is that money wealth is being destroyed, insofar as the debts of of debtor are considered assets to the creditor, and that the creditor can make loans on the strength of those assets.
The bank (or other creditor) has to wipe out the loan or lien. Literally, the value of these is reduced or zeroed out.
Debt forgiveness has an ancient tradition. It's part of some of the earliest legal codes (debt sabbaticals would occur every seventh year), and is included in the Catholic version of the Lord's Prayer, though protestants generally exchange "trespasses" for "debts".
Common stock is probably worthless and secured creditors will get some percentage of their loan back. The hope is the company can re-organize when relieved of debts they can't pay and creditors will get back more money than they would if they forced the company to close and auction off the assets.
thankfully Wikipedia is back: