code: def handle_unregistration(config, pconn):
      
      if config.legacy_upload:
          return _legacy_handle_unregistration(config, pconn)
      unreg = pconn.unregister()
      if unreg:
          # only set if unreg was successful
          write_unregistered_file()
          get_scheduler(config).remove_scheduling()
      return unreg
docs: Returns:
          True - machine was successfully unregistered
          False - machine could not be unregistered
          None - could not reach the API