Get your taxes done using TurboTax

The mortgage pay off is not relevant to what your profit is. Your gain is the difference between the amount of the sale minus costs of the sale and minus what you paid for the home and capital improvements.