def METHOD_NAME():
    """
    Deactivate an environment and collect corresponding environment modifications.
    Note: unloads the environment in its current state, not in the state it was
        loaded in, meaning that specs that were removed from the spack environment
        after activation are not unloaded.
    Returns:
        spack.util.environment.EnvironmentModifications: Environment variables
        modifications to activate environment.
    """
    env_mods = EnvironmentModifications()
    active = ev.active_environment()
    if active is None:
        return env_mods
    if ev.default_view_name in active.views:
        try:
            with spack.store.STORE.db.read_transaction():
                active.rm_default_view_from_env(env_mods)
        except (spack.repo.UnknownPackageError, spack.repo.UnknownNamespaceError) as e:
            tty.warn(e)
            tty.warn(
                "Could not fully deactivate view due to missing package "
                "or repo, shell environment may be corrupt."
            )
    ev.METHOD_NAME()
    return env_mods