diff --git a/common-channel.c b/common-channel.c
index f03039a174536c6f69339f5d8f01297c9c2f5868..dfff1b4dc47e4e044010c478a45fced454156bdd 100644
--- a/common-channel.c
+++ b/common-channel.c
@@ -1019,6 +1019,7 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
 
 	/* XXX server */
 	if (channel->type->sepfds) {
+		TRACE(("shutdown((%d), %d)", fd, how))
 		shutdown(fd, how);
 		if (how == 0) {
 			closeout = 1;
@@ -1043,4 +1044,11 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
 	if (closein && (channel->extrabuf != NULL) && (fd == channel->errfd)) {
 		channel->errfd = FD_CLOSED;
 	}
+
+	/* if we called shutdown on it and all references are gone, then we 
+	 * need to close() it to stop it lingering */
+	if (channel->type->sepfds && channel->outfd == FD_CLOSED 
+		&& channel->infd == FD_CLOSED && channel->errfd == FD_CLOSED) {
+		close(fd);
+	}
 }