Ensure that the path to the socket is cleaned up when detaching

Currently the path to the socket was only cleaned up on exit. Was having issues trying to attach/detach from the same process.