It is not automatic. Whether you need to cancel depends on the gap: if your last working day is close to the work permit's expiry, you don't need to cancel; if there is a significant gap, you must cancel it and get a cancellation certificate.
Nationwide (all cities)
Not automatic
Cancellation of the work permit is not automatic. You must judge the situation yourself based on the gap between your last working day and the work permit's expiry date, as the Shenzhen Guangming District government explains.
No cancellation needed
There are two scenarios. If your last day of work coincides with, or is very close to, the expiry date of your work permit, there is no need to cancel it. This is because the cancellation process must be initiated a few days before you leave, and a permit that is about to expire on its own does not create a lingering status.
Must cancel
If, however, there is a significant time gap between your resignation and the expiry of your work permit, you must cancel it. To do this, you obtain a work permit cancellation certificate from the Bureau of Foreign Experts Affairs. This certificate matters if you plan to return to China within a short period and apply for a domestic work permit transfer.
The rule of thumb
So the rule is: a gap means you cancel it yourself; a near-expiry permit means you can leave it. Leaving a permit un-cancelled when there is a gap leaves an unresolved status that can complicate a future return.