Cleanup socket status logging

Make sure the socket monitoring sockets are closed prior to calling
zmq_term, otherwise you got a deadlock on your hands.