[TCP] Reworked the closewait function