shutting down socket properly