What
@Benj****
said;
You go cancel your work permit, you take that and the termination paperwork to the immigration office and they cancel your current extension.
Most people do this a couple weeks BEFORE their actual termination date so that the extension is canceled on the date on the termination paperwork and then you just leave the country after that.
Canceling the extension the day you cancel the work permit works out like Ben said, you get your extension canceled, then if you can't leave that very day you BUY a 7 day extension denied stamp for 1900baht to get out of the country in a week