def download_if_unfinished(api_instance, n_jobs=1):
    """
    Download undownloaded files and terminate execution

    Parameters
    ----------
    api_instance: vds_api_client.VdsApiV2
        VdsApiV2 instance which after initialization has a uuids
        attribute that is either filled or not
    n_jobs: int
    """
    if api_instance.uuids:
        api_instance.download_async_files(n_proc=n_jobs)
        api_instance.summary()
        api_instance.logger.info(
            ' ================== Finished ==================')
        exit(0)
