Ensure exit code is propagated via running cleanup in a separate thread.