Qualification for capital gain excursion on home sales

I am trying to understand the qualification of my home sale from Capital Gain excursion.

I have a house in NYC where I lived from   2009 until August 2022 then as of Sept, I have moved to NJ, updated Drivers license, file NJ state tax as residence.  The home has been used as a rental starting Nov 2022 and I just ask  the tenant to vacant the home.   (lets assume they are gone by Dec 2024)  In order to claim this as a primary home, do I have to close the sales of this house by August 2025? Or do I have the ability to treat this home as a primary home from Jan - Aug 2025 since I no longer rent it out and use for per personal purpose.  Also the home is 10 mins from my husband's work.  Does it provide qualification as a primary home?  We still fly as NYC non residence since he works out of NYC.