What should I do if my visa-free stay period is about to expire and I want to extend my stay?
english.shanghai.gov.cn
A: Visitors entering China under mutual visa exemption agreements must leave before their visa-free stay period ends. If an extension is required due to emergencies or force majeure, you must apply for a stay permit at the local exit-entry administration office of the public security bureau before the visa-free period expires.
Here is a guide for applying for a stay permit.
Source: Shanghai Municipal Bureau of Public Security