Fix error of unclosed threads after session and client was disconnected.