Fix shutdown race conditions by updating to the new core API