You get the termination papers from your employer. Go to Chamchuri to apply for the cancellation of your work permit and an extension. As your current employer is a BOI company, most likely you may be stamped for
****
/21 days grace period to leave Thailand, free of charge. The number of days may differ depending on the company or other conditions. You can go for cancellation in advance, so you can see how many days you can get. Or contact Chamchuri in advance about the grace period in your case.
There were very few cases in which a person from a BOI company wasn't granted this grace period stamp. If this was your case unluckily, still, you can go to Chaengwattana to apply for another extension for whatever reason and get a normal application-denied-7-days-to-leave-the-kingdom stamp by paying 1900 thb, the standard extension fee.