Which means you stop working, so there is only 1 option.
Get the letter from your employer, visit your local Immigration Office, cancel your Extension of Stay, ending on the same date as last day of employment and apply for a new 1 year Extension of Stay based on visiting Thai family.
And visit the Ministry of Labor to cancel your work permit.
IF
you are in Thailand during the first 90 days you got on entry or at conversion of your stay at local Immigration Office, than you visit your local immigration office and ask IF you can apply for the 1 year Extension of Stay based on visiting Thai family, if not than you need to go abroad to apply for a new visa.
Get the Emergency passport, travel abroad, come back with the Visa Exempt Entry, wait for your new passport and start the visa procedures all over again, starting with new Non Immigrant visa for 90 days and than the 1 year Extension of Stay
To apply inside Thailand for a new visa, you must meet the requirements and NOT all of the over 80 Immigration Offices have the permission to issue visa.
The question now is:
Does the office you visited have permission to issue a visa?
Did you meet all the requirements, like entered with a Visa Exempt Entry OR Tourist Visa, did you have enough days left as this application goes under consideration?
IF an Immigration Officer told you to go abroad to apply, I'm almost certain that the answer on one or even both questions is NO
some said, but even when it makes sense by foreigners it does not mean it is correct.
This is a copy of the police order.
BTW it is NOT a retirement visa, but an 1 year Extension of Stay based on being over 50 years of age and willing to sit out the rest of your life in Thailand, (shortcut retirement)