Capital gains don’t take into account how much you owe. All that matters is how much you sell it for: Previously you said $1MM,
minus selling costs like commissions, recording fees, etc. - say $80k
minus your basis of $670k purchase + $50k in upgrades, or $720k
My previous comment assumed you bought the house long ago at a lower price. In this case, because the house was purchased more recently, the capital gains are lower, and within the exemption limit, both MFJ and Single limits!
$1M - $50k selling costs - $50k home upgrades - $670k original basis = $230k capital gain.
You should probably still close before finalizing because otherwise you pay the entire $50k closing costs instead of sharing them equally.
Since they’re presumably both on the title to the house and @sfatva isn’t buying the ex out, even after the divorce, they would still share in the closing costs.