Add user cancellation to the C API.