Our current behavior is non-deterministic. We create a detached thread to close connected sockets, but don't ensure that the thread ever even starts before we go on to terminate the process. As a result, we may close no sockets, some sockets, or all of the sockets.
Due to a bug in ASAN (see linked tickets), we currently also end up reporting a false positive memory leak in the event that we terminate the process before the detached thread begins working.
We could join the thread, waiting for it to finish shutting down all sockets, but this could take a very long time in some cases (the reason the background thread was originally introduced). We could also give the thread a grace period of time, and then detach it if it hasn't finished, but that doesn't really solve anything - we still wouldn't be assured that the thread had started, and we still wouldn't be sure that we had closed all of the sockets, so the situation would still be non-deterministic.
Given that, our current thinking is that it is better to just terminate the process and let the OS clean up the sockets for us.