At any time, the PSB Exit and Entry Administration can cancel your visa or residence permit. Of course, this is unusual and would occur only if you are deemed not to be complying with regulations relating to the visa or you have broken Chinese law. If the offence is serious enough you could be expelled under escort by the police, but for lesser situations you are normally allowed 7 days to exit the mainland or if you don’t already have one, granted a 7 day tourist L, to enable you to organise and exit China.
A common issue is that when you have entered China on a Z or X but later leave your employment or studies, you are not entitled to remain on that issued visa. The organisation you were associated with is supposed to notify the PSB that you are no longer with them and you should apply for a new one, most likely a tourist (L).
If you do not seek a new visa and the PSB has been notified of the situation, you will probably have no trouble until you seek to leave the country. Then you might be considered to have overstayed your visa.
Even if you have a visa to China (or maybe you do not need one) your airline might refuse to allow you to board. This is because airlines face penalties from governments if passengers are not eligible for entry to a country and they are also responsible for carrying them out again. Generally, there is no problem if you have onward (or return) tickets. If you don’t have one of these, you might run into difficulties. If you are planning to work or study for a year you might not want to buy a return ticket, so this can be a problem. Sometimes you can overcome the problem by buying a refundable or partially refundable ticket in advance, or booking hotels in the next destination and perhaps forfeiting the deposit.
In situations where there might be some doubt you should check with your airline in advance and if they accept your situation try to get that in writing. Each airline decides its own approach to this issue so check more than one before you purchase.