Nicholos Senior.
To quit your job you inform first your employer, best with a letter with end date of employment.
Than you go to Minsitry of Labor to cancel your work permit on day you quit working.
Than you go to Immigration Office, if you stay inside Thailand on an Extension of Stay, with the papers from Ministry of Labor to cancel your Extension of Stay at the date you stop working. You can do this in advance. If you meet requirements you can apply for new Extension of Stay if not you have to leave the country and if you like to come back organize a Visa or use the Visa Exempt Entry.
TLDR : Answer Summary
To cancel your work permit and Extension of Stay after quitting a job in Thailand, first inform your employer and provide a resignation letter. On your last working day, visit the Ministry of Labor to cancel your work permit. Then, go to the Immigration Office with documents from the Ministry to cancel your Extension of Stay, which can be done in advance. If you meet requirements, you may apply for a new Extension; otherwise, you'll need to leave Thailand.