En la imagen adjunta se visualiza el ciclo de vida de una conecion TCP
NOTE: It is normal to have a socket in the TIME_WAIT state for a long period of time. The time is specified in RFC793 as twice the Maximum Segment Lifetime (MSL). MSL is specified to be 2 minutes. So, a socket could be in a TIME_WAIT state for as long as 4 minutes. Some systems implement different values (less than 2 minutes) for the MSL. CLOSE_WAIT means that the local end of the connection has received a FIN from the other end, but the OS is waiting for the program at the local end to actually close its connection.
La diferencia entre uno y otra estado radica en el sistema que solicita el cierre de la conexion:
TIPs
Utilizar el siguiente comando para visualizar las conexiones, sus estados y tiempos, netstat -oanltp
Se puede modificar el tiempo en estado TIME_WAIT, en el SO Linux se debe modificar el valor del parametro /proc/sys/net/ipv4/tcp_fin_timeout, ejemplo: agregar la siguiente linea en el archivo /etc/sysctl.conf, net.ipv4.tcp_fin_timeout = 30 (para que el cambio tome efecto ejecutar /sbin/sysctl -p)