async def METHOD_NAME(
    app: web.Application,
    dynamic_service: dict[str, Any],
    currently_opened_projects_node_ids: dict[str, str],
) -> None:
    """ "orphan" is a service who is not present in the DB or not part of a currently opened project"""
    service_host = dynamic_service["service_host"]
    service_uuid = dynamic_service["service_uuid"]
    # if not present in DB or not part of currently opened projects, can be removed
    # if the node does not exist in any project in the db
    # they can be safely remove it without saving any state
    if not await is_node_id_present_in_any_project_workbench(app, service_uuid):
        _logger.info(
            "Will remove orphaned service without saving state since "
            "this service is not part of any project %s",
            f"{service_host=}",
        )
        try:
            await api.stop_dynamic_service(
                app,
                service_uuid,
                simcore_user_agent=UNDEFINED_DEFAULT_SIMCORE_USER_AGENT_VALUE,
                save_state=False,
            )
        except DirectorServiceError as err:
            _logger.warning("Error while stopping service: %s", err)
        return
    # if the node is not present in any of the currently opened project it shall be closed
    if service_uuid not in currently_opened_projects_node_ids:
        if service_state := dynamic_service.get("service_state") in [
            "pulling",
            "starting",
        ]:
            # Services returned in running_interactive_services
            # might be still pulling its image and when stop_service is
            # called, will cancel the pull operation as well.
            # This enforces next run to start again by pulling the image
            # which is costly and sometimes the cause of timeout and
            # service malfunction.
            # For that reason, we prefer here to allow the image to
            # be completely pulled and stop it instead at the next gc round
            #
            # This should eventually be responsibility of the director, but
            # the functionality is in the old service which is frozen.
            #
            # a service state might be one of [pending, pulling, starting, running, complete, failed]
            _logger.warning(
                "Skipping %s since service state is %s",
                f"{service_host=}",
                service_state,
            )
            return
        _logger.info("Will remove service %s", service_host)
        try:
            # let's be conservative here.
            # 1. opened project disappeared from redis?
            # 2. something bad happened when closing a project?
            user_id = int(dynamic_service.get("user_id", -1))
            user_role: UserRole | None = None
            try:
                user_role = await get_user_role(app, user_id)
            except (UserNotFoundError, ValueError):
                user_role = None
            project_uuid = dynamic_service["project_id"]
            save_state = await ProjectDBAPI.get_from_app_context(app).has_permission(
                user_id, project_uuid, "write"
            )
            if user_role is None or user_role <= UserRole.GUEST:
                save_state = False
            # -------------------------------------------
            with contextlib.suppress(ServiceWaitingForManualIntervention):
                await api.stop_dynamic_service(
                    app,
                    service_uuid,
                    UNDEFINED_DEFAULT_SIMCORE_USER_AGENT_VALUE,
                    save_state=save_state,
                )
        except DirectorServiceError as err:
            _logger.warning("Error while stopping service: %s", err)