Fix hang when sending packets on closed connection