Foreign firms, after years of reinvesting their Chinese earnings in China, have begun to pull out their money.