fix tcp server close logic