diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 900b5a3b..706195ac 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -718,7 +718,10 @@ multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool sh
     set_cc_config(mi, NULL);
 #endif
 
-    if (mi->context.c2.tls_multi->multi_state >= CAS_CONNECT_DONE)
+    /* A client that failed in multi_client_connect_late_setup() is in
+     * CAS_FAILED, but its client-connect handlers did succeed */
+    if (mi->context.c2.tls_multi->multi_state >= CAS_CONNECT_DONE
+        || (mi->did_client_connect && mi->context.c2.tls_multi->multi_state == CAS_FAILED))
     {
         multi_client_disconnect_script(mi);
     }
@@ -2414,6 +2417,15 @@ multi_client_connect_late_setup(struct multi_context *m, struct multi_instance *
     /* set context-level authentication flag */
     mi->context.c2.tls_multi->multi_state = CAS_CONNECT_DONE;
 
+    /* We only get here if all client-connect handlers succeeded, so a
+     * defined client-connect plugin or script has been called with
+     * success. Remember this, as the steps below may still set
+     * CAS_FAILED, and the client-disconnect handlers must then be called
+     * when the instance is closed. */
+    mi->did_client_connect = plugin_defined(mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT)
+                             || plugin_defined(mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT_V2)
+                             || mi->context.options.client_connect_script != NULL;
+
     /* Since dco-win maintains iroute routing table (subnet -> peer),
      * peer must be added before iroutes. For other platforms it doesn't matter. */
 
diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h
index 3d2e9321..9cc986c9 100644
--- a/src/openvpn/multi.h
+++ b/src/openvpn/multi.h
@@ -145,6 +145,9 @@ struct multi_instance
     struct buffer_list *cc_config;
 #endif
     bool did_iroutes;
+    /** a client-connect plugin or script was called and succeeded, so
+     * client-disconnect must be called when the instance is closed */
+    bool did_client_connect;
     int n_clients_delta;    /* added to multi_context.n_clients when instance is closed */
 
     struct context context; /**< The context structure storing state
