When you sell a personal residence, the tax you owe is figured on the gain you have from the sale. It has nothing to do with how much your ended up with after paying off the mortgages.
Your gain is figured by taking the sale price of the home less your basis, less the cost of any real estate commissions. Your basis in the home is what you originally paid for it plus the cost of any improvements you made while you owned it.
As an example, if you paid $200,000 for a home and added another $50,000 in improvements, your basis would be $250,000. If you then sold the home for $400,000, you would have a taxable gain of $150,000. That gain would also be reduced by any real estate commissions you paid.
When you sell a primary residence, you are allowed to exclude the first $250,000 from tax. That exclusion is increased to $500,000 for married taxpayers filing a joint return. If your gain exceeds those exclusion amounts, the excess gain is subject to long term capital gains tax which is currently capped at 15%. Other than the allowed exclusion on the sale, there are no other tax shelters that would apply here.
If this was helpful please press the Accept button. It is the only way we receive any credit for helping with these questions.