NetMQ causes infinite application reload (solved)

I have a very simple “Hello World” NetMQ script, and nothing else of import running:
(NOTE: InfoManager.SetText() is a custom method of mine which changes text on an object, this can be completely ignored)

using NetMQ;
using NetMQ.Sockets;
using System.Threading;
using UnityEngine;
using System.Collections;

public class ZeroMQScript : MonoBehaviour
{
    ResponseSocket server;
    RequestSocket client;

    private void Start()
    {
        //Necessary line, not sure why.
        AsyncIO.ForceDotNet.Force();

        //creating sockets
        Debug.Log("Creating server socket");
        server = new ResponseSocket();
        server.Bind("tcp://*:5555");
        Debug.Log("Creating client socket");
        client = new RequestSocket();
        client.Connect("tcp://localhost:5555");
    }

    private void Update()
    {
        Server(server);
    }

    void Server(ResponseSocket server)
    {
        if (server.TryReceiveFrameString(out var message))
        {
            InfoManager.SetText("Received " + message);
            // processing the request
            Thread.Sleep(100);
            InfoManager.SetText("Sending World");
            server.SendFrame("World");
        }
    }

    public void ClientSendHello()
    {
        InfoManager.SetText("Sending Hello");
        if (client.TrySendFrame("Hello"))
        {
            StartCoroutine(GetResponse());
        }
        else
        {
            InfoManager.SetText("Failed to send message.");
        }
    }

    IEnumerator GetResponse()
    {
        yield return null;
        Thread.Sleep(100);
        if (client.TryReceiveFrameString(out var message))
        {
            InfoManager.SetText("Received " + message);
        }
        else
        {
            InfoManager.SetText("Received no message.");
        }
    }

    private void OnApplicationQuit()
    {
        client.Close();
        server.Close();
    }
}

When i execute this, It works perfectly fine, but If I stop the application, and modify my script (nothing major, just add a comment) to cause the application to reload on unity, it reloads forever, and all I can do is kill Unity on the task manager and reopen my project (which applies the script changes).

7572370--937831--upload_2021-10-14_16-49-6.png
(NOTE: It got to the point where it was doing this reload for over 20 mins, which is not normal)

Why does this happen and what can I do? Any help would be appreciated.

Solution: After closing the sockets, it is also necessary to call “NetMQConfig.Cleanup();”, since NetMQ runs some background threads that must also be closed. My infinite reloading was caused by these threads still being run, and Unity waiting for them to close.