Is that how filing for bankruptcy works?

That's how chapter 11 type bankruptcy works. The business continues to run but the debtors are now the owners. There's also chapter 7 where the business shuts down and stripped for parts to pay the debts.

Yeah, Trump went bankrupt 3 times, and he's still here