Fix shutdown for C apps.