Clean up sockets to prevent socket exhaustion