Fixed possible race condition, when messages can be received after session was closed