Add more code to force closing of sockets