The filing of a bankruptcy will stay (stop) a foreclosure, at least temporarily.
If a Chapter 7 is filed, the mortgage lender can obtain relief from the bankruptcy stay to continue the forecloseure if the debtor has not brought the mortgage payments current.
If a Chapter 13 is filed and the Chapter 13 plan provides for payment of the past due mortgage payments over time, the mortgage lender cannot obtain permission to foreclose unless the debtor fails to make the mortgage payments that are currently due.
CAN I MODIFY MY MORTGAGE TERMS?
This can be done in a Chapter 13 bankruptcy if the mortgage lender cooperates.