Upon leaving China, if you still have some local money, you can change them back to foreign currency with your passport and the exchange memos given by the banks or money exchange counters. So please keep those exchange memos well whenever you change money.