State tax filing

If I become a Florida resident on Jan. 1, 2024, do I have to sell and close on my NJ home by Jan. 1, 2027 to be eligible for the $500K capital gain exclusion?  That would be 3 years (2024, 2025 and 2026).

 

Thanks again.