Close connections on API errors.