Disable HTTP/S server on runtime without restart

Hi, my goal is to disable http server at runtime without device restart.
I looked into documentation of http server library, but there is no deinitialization function. So i’m not able switch off http server at runtime.
I expect that there should be some clean way to turn http server off. But this probably needs to be implemented in mongoose os. But for now the “unclean” way is enough for me.
It’s not important for me that some resources will be still allocated after disabling http server.
So my question is: How to unbind http/https port that was bound by mgos_init_http() function?

Thank you.

You can close the connection:

  struct mg_connection *http = mgos_get_sys_http_server();
  if (http != NULL) {
    http->flags |= MG_F_CLOSE_IMMEDIATELY;
  }

Thank you. So nice and simple. But when the connection will be closed? Immediately from mg event loop?