Rental property

We have a rental house that is next door to our primary residence.  It was rented out from 2017 through 18 July 2025 and was converted to personal use on 19 July 2025 so we would have a place for my 96-y.o. mother.  We plan to either sell or re-rent the property in mid-2026.  When I enter the days or personal use in TurboTax, it does the calculations to split between personal and business use as expected, but it also allows the loss for the part of the year it was rental property.  Up until now, all my losses have been carried forward.  I'm happy to get the deduction, but what happens when I sell the house in 2026?  We would have about 180-200 days of personal use prior to the sale.  I'm assuming we'll still have to pay capital gains on the gain on the property as if it were still an rental property, but will we still be able to deduct the losses carried forward from 2017 through 2024?