diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c
index 7031c199ccf67cf8acbfbec2a6bcdbec01272608..3c65f478bc341026b87097cf58293e8596b97fac 100644
--- a/servers/slapd/connection.c
+++ b/servers/slapd/connection.c
@@ -36,6 +36,7 @@ void slapd_remove(int s);
 static Connection* connection_get( int s );
 
 static int connection_input( Connection *c );
+static void connection_close( Connection *c );
 
 static int connection_op_activate( Connection *conn, Operation *op );
 static int connection_resched( Connection *conn );
@@ -54,7 +55,7 @@ int connections_init(void)
 
 	assert( connections == NULL );
 
-	if( connections != NULL) { /* probably should assert this */
+	if( connections != NULL) {
 		Debug( LDAP_DEBUG_ANY, "connections_init: already initialized.\n",
 			0, 0, 0 );
 		return -1;
@@ -83,6 +84,59 @@ int connections_init(void)
 	return 0;
 }
 
+/*
+ * Destroy connection management infrastructure.
+ */
+int connections_destroy(void)
+{
+	int i;
+
+	/* should check return of every call */
+
+	if( connections == NULL) {
+		Debug( LDAP_DEBUG_ANY, "connections_destroy: nothing to destroy.\n",
+			0, 0, 0 );
+		return -1;
+	}
+
+	for ( i = 0; i < dtblsize; i++ ) {
+		ldap_pvt_thread_mutex_destroy( &connections[i].c_mutex );
+		ldap_pvt_thread_mutex_destroy( &connections[i].c_write_mutex );
+		ldap_pvt_thread_cond_destroy( &connections[i].c_write_cv );
+
+		free( &connections[i] );
+	}
+
+	free( connections );
+	connections = NULL;
+
+	ldap_pvt_thread_mutex_destroy( &connections_mutex );
+	return 0;
+}
+
+/*
+ * shutdown all connections
+ */
+int connections_shutdown(void)
+{
+	int i;
+
+	ldap_pvt_thread_mutex_lock( &connections_mutex );
+
+	for ( i = 0; i < dtblsize; i++ ) {
+		if( connections[i].c_struct_state != SLAP_C_USED ) {
+			continue;
+		}
+
+		ldap_pvt_thread_mutex_lock( &connections[i].c_mutex );
+		connection_closing( &connections[i] );
+		connection_close( &connections[i] );
+		ldap_pvt_thread_mutex_unlock( &connections[i].c_mutex );
+	}
+
+	ldap_pvt_thread_mutex_unlock( &connections_mutex );
+}
+
 static Connection* connection_get( int s )
 {
 	Connection *c = NULL;
@@ -310,11 +364,17 @@ connection_destroy( Connection *c )
 
 int connection_state_closing( Connection *c )
 {
+	int state;
 	assert( c != NULL );
 	assert( c->c_struct_state == SLAP_C_USED );
-	assert( c->c_conn_state != SLAP_C_INVALID );
 
-	return c->c_conn_state == SLAP_C_CLOSING;
+    ldap_pvt_thread_mutex_lock( &c->c_mutex );
+	state = c->c_conn_state;
+    ldap_pvt_thread_mutex_unlock( &c->c_mutex );
+
+	assert( state != SLAP_C_INVALID );
+
+	return state == SLAP_C_CLOSING;
 }
 
 void connection_closing( Connection *c )
diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c
index 1f20c881a4fc6bc7e9df368a6e8f71919f9515ba..05a38dbd9c5d67adf18747cc5dee31b93b8c55a5 100644
--- a/servers/slapd/daemon.c
+++ b/servers/slapd/daemon.c
@@ -232,8 +232,6 @@ slapd_daemon_task(
 
 	slapd_listener=1;
 
-	connections_init();
-
 	ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
 	FD_ZERO( &slap_daemon.sd_readers );
 	FD_ZERO( &slap_daemon.sd_writers );
@@ -582,6 +580,9 @@ slapd_daemon_task(
 		tcp_close( tcps );
 	}
 
+	/* we only implement "quick" shutdown */
+	connections_shutdown();
+
 	ldap_pvt_thread_mutex_lock( &active_threads_mutex );
 	Debug( LDAP_DEBUG_ANY,
 	    "slapd shutdown: waiting for %d threads to terminate\n",
@@ -602,6 +603,8 @@ int slapd_daemon( int inetd, int tcps )
 	args[0] = inetd;
 	args[1] = tcps;
 
+	connections_init();
+
 #define SLAPD_LISTENER_THREAD 1
 #if SLAPD_LISTENER_THREAD
 	/* listener as a separate THREAD */
@@ -622,6 +625,7 @@ int slapd_daemon( int inetd, int tcps )
 	slapd_daemon_task( args );
 #endif
 
+	connections_destroy();
 	return 0;
 }
 
diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h
index d35ab85802ffc7fb24877fd6494e97756a42806d..e31aff18a3a4b212abe4d0cd0a69ba7456c21c23 100644
--- a/servers/slapd/proto-slap.h
+++ b/servers/slapd/proto-slap.h
@@ -114,6 +114,8 @@ int read_config LDAP_P(( char *fname ));
  * connection.c
  */
 int connections_init LDAP_P((void));
+int connections_shutdown LDAP_P((void));
+int connections_destroy LDAP_P((void));
 
 long connection_init LDAP_P((
 	int s,