The mortgage payout is often the piece sellers underestimate. Your lender calculates the exact payout figure, including any accrued interest and prepayment penalty for breaking the term early, and that number can shift the closer you get to your actual closing date, so ask for an updated figure a few weeks out rather than relying on an old mortgage statement.
Your lawyer holds the sale proceeds in trust through Information Services Corporation and disburses funds only after the mortgage is paid out, commission is paid, and any other registered charges against the title are cleared, so what reaches your account is genuinely the final number.
Getting an accurate sale price estimate first is what makes the rest of this math meaningful. Get your hand-reviewed valuation from Joel Dyck.