How to close the websocket connection normally?

Hello everyone, excuse me. In my AAX plugin, in order to transfer data to HTML pages, I used websocket and the websocketpp library. Firstly, I used the server g_ The server is used as a global variable, and the following is my initialization process

g_server.init_asio();
            initlog=initlog+"\n init_asio--";
//            g_server.set_reuse_addr(true);
            g_server.listen(9000);
            // Register our message handler
            g_server.set_open_handler(bind(&on_open, &g_server, ::_1));
            g_server.set_message_handler(bind(&on_message1, &g_server, ::_1, ::_2));
            g_server.set_close_handler(bind(&on_close, &g_server, ::_1));
            // Listen on port 9002

            // Start the server accept loop
            g_server.start_accept();

I attempted to call the destroy method when all plugins were closed

g_server.stop_listening();
        g_server.stop();
        g_server.close(g_hdl, websocketpp::close::status::normal, "close");

At this point, I will throw an exception when reopening the plugin on server.init

[library] asio::init_asio called from the wrong state

How should I properly destroy it?

Or do I want to destroy the websocket connection when the DAW software is shut down? Is there any way to do this?