Prevent IllegalStateException when the request gets closed