Detection of remotely closed connection