Make sure socket is closed where/when it needs to be