Index: tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.150
diff -u -r1.150 tclIO.c
--- tclIO.c	25 Nov 2008 23:19:01 -0000	1.150
+++ tclIO.c	1 Dec 2008 16:57:39 -0000
@@ -299,7 +299,7 @@
 		statePtr != NULL;
 		statePtr = statePtr->nextCSPtr) {
 	    chanPtr = statePtr->topChanPtr;
-	    if (!(statePtr->flags & CHANNEL_DEAD)) {
+	    if (!(statePtr->flags & (CHANNEL_INCLOSE|CHANNEL_CLOSED|CHANNEL_DEAD))) {
 		active = 1;
 		break;
 	    }
@@ -364,8 +364,8 @@
 		 */
 
 		chanPtr->instanceData = NULL;
+		SetFlag(statePtr, CHANNEL_DEAD);
 	    }
-	    SetFlag(statePtr, CHANNEL_DEAD);
 	}
     }
 
