It should not say "proceeds", it should say "Selling price." You can add certain closing costs to your adjusted cost basis, but not all closing costs. There is a list in publication 523.
https://www.irs.gov/pub/irs-pdf/p523.pdf
Your profit is also not affected by any mortgage. If your selling price was $100,000 but you only received $50,000 because there was an outstanding mortgage, your selling price for the capital gains calculation is still $100,000.