You put a hold on their ability to run for office. Can’t run for some amount of time after changing to prevent exactly this. Context for those who didn’t RTFA:
The next day, Penzone’s chief deputy, Russell Skinner, changed his party affiliation from Republican to Democrat and won the spot.