Each state has their own specific residency requirements. They also have their own specific requirements to not be a resident, or to terminate residency status. So it depends on the states involved here.
Basically, you may end up filing a part-year residence tax return for each state, depending.