- tc->state = TCP_STATE_CLOSED;
- TCP_EVT_DBG (TCP_EVT_STATE_CHANGE, tc);
+ /* Make sure we mark the session as closed. In some states we may
+ * be still trying to send data */
+ session_stream_close_notify (&tc->connection);
+ tcp_connection_set_state (tc, TCP_STATE_CLOSED);