The bank will not discharge the mortgage until their loan is repaid. So you will need to come up with the full amount of the loan in order to settle - ie pay the bank another $40k at settlement, based on your example.
LMI will only help the bank if you default and cannot pay. It won't help you.