diff -r 028fa77f952f common-channel.c
--- a/common-channel.c	Mon Jul 08 22:43:56 2013 +0800
+++ b/common-channel.c	Wed Jul 24 21:05:38 2013 -0400
@@ -307,7 +307,10 @@
 		return;
 	}
 
-	if (channel->recv_eof && !write_pending(channel)) {
+	if ((channel->recv_eof
+			 /* have a server "session" and child has exited */
+			 || (channel->type->check_close && close_allowed))
+			&& !write_pending(channel)) {
 		close_chan_fd(channel, channel->writefd, SHUT_WR);
 	}
 
@@ -336,6 +339,7 @@
 
 	/* And if we can't receive any more data from them either, close up */
 	if (channel->readfd == FD_CLOSED
+			&& channel->writefd == FD_CLOSED
 			&& (ERRFD_IS_WRITE(channel) || channel->errfd == FD_CLOSED)
 			&& !channel->sent_close
 			&& close_allowed
