Stop the specified service

    Args:
        name (str): The name of the service to stop

        timeout (int):
            The time in seconds to wait for the service to stop before
            returning. Default is 90 seconds

            .. versionadded:: 2017.7.9,2018.3.4

        with_deps (bool):
            If enabled stop the given service and the services
            the current service depends on.

        with_parents (bool):
            If enabled and in case other running services depend on the to be stopped
            service, this flag indicates that those other services will be stopped
            as well.
            If disabled, the service stop will fail in case other running services
            depend on the to be stopped service.

    Returns:
        bool: ``True`` if successful, otherwise ``False``. Also returns ``True``
            if the service is already stopped

    CLI Example:

    .. code-block:: bash

        salt '*' service.stop <service name>

def stop(name, timeout=90, with_deps=False, with_parents=False):
    '''
    Stop the specified service

    Args:
        name (str): The name of the service to stop

        timeout (int):
            The time in seconds to wait for the service to stop before
            returning. Default is 90 seconds

            .. versionadded:: 2017.7.9,2018.3.4

        with_deps (bool):
            If enabled stop the given service and the services
            the current service depends on.

        with_parents (bool):
            If enabled and in case other running services depend on the to be stopped
            service, this flag indicates that those other services will be stopped
            as well.
            If disabled, the service stop will fail in case other running services
            depend on the to be stopped service.

    Returns:
        bool: ``True`` if successful, otherwise ``False``. Also returns ``True``
            if the service is already stopped

    CLI Example:

    .. code-block:: bash

        salt '*' service.stop <service name>
    '''
    ret = set()

    services = ServiceDependencies(name, get_all, info)
    stop = services.stop_order(with_deps=with_deps, with_parents=with_parents)
    log.debug("Stopping services %s", stop)
    for name in stop:
        try:
            win32serviceutil.StopService(name)
        except pywintypes.error as exc:
            if exc.winerror != 1062:
                raise CommandExecutionError(
                    'Failed To Stop {0}: {1}'.format(name, exc.strerror))
            log.debug('Service "%s" is not running', name)

        srv_status = _status_wait(service_name=name,
                                  end_time=time.time() + int(timeout),
                                  service_states=['Running', 'Stop Pending'])
        ret.add(srv_status['Status'] == 'Stopped')
    return False not in ret