Yes. Foreign (and HK/MO/TW) employees can withdraw the housing provident fund after the employer closes (seals) the account upon termination. It can be done online or at a counter, and the account must be in 'sealed' status first.
Nationwide (all cities)
Housing fund vs. social insurance
Note: the housing provident fund is a separate pot from social insurance. Leaving China lets you withdraw the provident fund; the social insurance (pension) individual account is handled under a different rule (see the social insurance questions).
Local variations
Beijing
Beijing: the guide 'Withdrawal of Housing Provident Fund upon Termination for Foreigners and HK/MO/TW Personnel' states that foreign, HK, MO and TW workers in Beijing, after terminating with the employer and after the employer has sealed (封存) the individual account, may apply for account-closing withdrawal. Two channels: (1) online via the Beijing Housing Provident Fund website (gjj.beijing.gov.cn) 'Personal Online Business Platform', selecting item '12. Foreign / HK / MO / TW account closing', uploading the ID and choosing the receiving bank; (2) at a counter with the original passport (or travel permit) and the completed authorization form, at any management department or entrusted bank outlet. The account status must be 'sealed' before the account-closing withdrawal can be processed, and the receiving account must be a Class I bank settlement account.
Guangzhou
Guangzhou: the guide 'Withdrawal upon Departure for Settlement Abroad' requires for foreign / HK / MO / TW employees who terminate and leave: the authorization form, the original termination material, and the original ID (matching the fund system record). Channels are online (the Guangzhou fund center website or WeChat service account) or at designated bank outlets. Approval takes no more than 3 working days, and the account must be sealed; with multiple accounts they must first be merged, and an outstanding housing-fund loan blocks the account-closing withdrawal.