Carl
Level 15

Investors & landlords

But when the sale is reported into TurboTax, it shows a gain

That's because you do have a gain in a sense. When you sell the rental property, you are required to recapture all prior depreciation taken and pay taxes on that recaptured depreciation in the year you sell the property. That recaptured depreciation is not exempt from taxation under any scenario, unless you sold the property for less than it's cost basis minus the depreciation.