If someone files bankruptcy, they can contact the company that holds the note to their home and agree to continue paying for and being responsible for the loan terms.
Reaffirming your mortgage is usually involved when you are filing bankruptcy. Your attorney will prepare a Reaffirmation Agreement which is basically when you and the mortgage company agree for you to continue paying your mortgage as you always have and you get to stay in your house. The mortgage will NOT be included in the bankruptcy.