What should I do if I need to leave the allowed areas for visa-free transit travelers or cannot depart within 240 hours due to special circumstances?
english.shanghai.gov.cn
If you are under the 240-hour visa-free transit, you are required to stay within the allowed areas for visa-free transit travelers in the 24 provinces (autonomous regions and municipalities), and depart within the permitted duration.
In case you have to stay beyond 240 hours or outside of the permitted areas due to special circumstances, you must apply for a stay permit with the exit-entry department of the public security bureau at the provincial or city level.
Source: Shanghai Exit-Entry Border Inspection General Station