A bankruptcy debtor can decide to surrender or keep their house in a Chapter 7 (assuming that the house has little or no equity and the trustee does not want to sell it for the benefit of creditors). If the debtor decides to surrender, the lender will probably file a foreclosure and the debtor can walk away scot-free.
If the debtor decides to keep the house, he basically has two options, only one of which is supported by the Code. Technically, if a debtor wants to keep the house, he has to reaffirm the debt under Section 524. Reaffirmation agreements are hardly advisable, however, because a debtor rarely will want to sign back on the line for hundreds of thousands of dollars to secure a house with little or no equity, especially since he just went through the time and expense to wipe out that very same liability.
Practically speaking, there is another option. A lot of debtors choose to "retain and pay" where they just keep making the payment even though their personal liability has been discharged. The hope is that the lender will not want to foreclose as long as they are getting regular payments. With this option, the debtor can still decide to walk away at any time in the future at no risk because he has not reaffirmed the debt.
The problem, however, is that mortgage lenders are not easy to deal with following a bankruptcy. Most lenders will stop sending mortgage statements to the debtor. They will also terminate any online access to the account that the debtor had set up. I always thought that the lenders feared violating the discharge injunction because sending a statement could be viewed as an attempt to collect a discharge debt.
That is not possible, though, because Section 524(j) says that lenders can take steps in the normal course of business to seek or obtain periodic payments in lieu of in rem relief to enforce their lien. In plain English, they can still send statements if they want to collect payments instead of filing foreclosure. Now, I guess that the reason they are difficult to deal with is that they want to force the debtors to reaffirm.