Reset state properly when tcp closing tcp connection