If a foreigner leaves a job for whatever reason, they need to hand back the work permit to the labour department and the visa that goes with that work permit becomes invalid. You then have to leave the country to obtain a new visa at a Thai embassy or consulate in the neighbouring countries.