Index: generic/tclIO.c
===================================================================
--- generic/tclIO.c
+++ generic/tclIO.c
@@ -412,12 +412,12 @@
 	active = 0;
 	for (statePtr = tsdPtr->firstCSPtr;
 		statePtr != NULL;
 		statePtr = statePtr->nextCSPtr) {
 	    chanPtr = statePtr->topChanPtr;
-	    if (!GotFlag(statePtr, CHANNEL_INCLOSE | CHANNEL_CLOSED |
-		    CHANNEL_DEAD)) {
+	    if (!GotFlag(statePtr, CHANNEL_INCLOSE | CHANNEL_CLOSED | CHANNEL_DEAD)
+                || GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
 		active = 1;
 		break;
 	    }
 	}
 
@@ -456,10 +456,11 @@
 	    } else {
 		/*
 		 * The refcount is greater than zero, so flush the channel.
 		 */
 
+                ResetFlag(statePtr, BG_FLUSH_SCHEDULED);
 		Tcl_Flush((Tcl_Channel) chanPtr);
 
 		/*
 		 * Call the device driver to actually close the underlying
 		 * device for this channel.

Index: tests/ioCmd.test
===================================================================
--- tests/ioCmd.test
+++ tests/ioCmd.test
@@ -2590,10 +2590,11 @@
     } c]
     set res
 } -cleanup {
     rename foo {}
     unset res
+    update
 } -result {{write rc* ABC} {watch rc* write} {}} \
     -constraints {testchannel testthread}
 
 # --- === *** ###########################
 # method cgetall

