Ok. Well in general when writing TCP/IP applications and a connection is closed, ideally you want the endpoint that is closing to send a message to the other endpoint telling it this. Relying solely on the TCP/IP network stack to manage this is a bad idea. In order to make TCP/IP connections reliable, they had to make it extremely forgiving when it comes to closed connections to support cases where the connection is intermittent. TCP/IP by design tries as much as possible to avoid assuming that a connection is closed when conditions are unclear.

My recommendation would to implement a message in your protocol that tells the server when a connection is being closed. This is the proper practice.