diff --git a/lib/output.c b/lib/output.c
index 465cb5f7eb8f8fcdce2c4bafe1b642b25a41edcf..c0ad1f8d6d0697a80de4855b463a3361c33a6ac1 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -315,9 +315,12 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf, size_t len,
 
 	if (wsi->state != LWSS_ESTABLISHED &&
 	    ((wsi->state != LWSS_RETURNED_CLOSE_ALREADY &&
+	      wsi->state != LWSS_WAITING_TO_SEND_CLOSE_NOTIFICATION &&
 	      wsi->state != LWSS_AWAITING_CLOSE_ACK) ||
-			    wp != LWS_WRITE_CLOSE))
+			    wp != LWS_WRITE_CLOSE)) {
+		lwsl_debug("binning\n");
 		return 0;
+	}
 
 	/* if we are continuing a frame that already had its header done */