Moved the check for already closed to make sure we honor this check when `immediate` flushing is requested