stop-service — PowerShell's stop-service cmdlet — like systemctl stop across all 5 shells
Equivalents in every shell
sudo systemctl stop nginxsystemd: `systemctl stop <name>` sends `SIGTERM`, waits for `TimeoutStopSec` (default 90s), then `SIGKILL`. `systemctl kill <name>` skips the wait. SysV-init: `sudo service nginx stop`. Both block until the service exits — for fire-and-forget use `--no-block`. Returns 0 on success even if the service was already stopped.
sudo launchctl bootout system/com.example.svcmacOS launchd: modern API is `launchctl bootout <domain>/<service>` (10.10+); legacy `launchctl unload <plist>` still works. `launchctl stop <label>` halts the service WITHOUT unloading it (will restart on RunAtLoad / KeepAlive). On macOS 13+, prefer `launchctl bootout gui/$(id -u)/com.example.svc` for user agents.
Stop-Service -Name w3svcPowerShell-native cmdlet. Sends a `STOP` control signal via the SCM (Service Control Manager). Use `-Force` to stop a service that has DEPENDENT services (without `-Force`, the cmdlet errors out with the dependent list). `-PassThru` returns the resulting `[ServiceController]`. Requires elevation.
sc stop w3svcBuilt-in `sc stop <name>` sends a STOP control. `net stop <name>` is the older interface — prompts for confirmation if the service has dependents (and lists them). Both require elevation. `taskkill /f /im <process>.exe` kills the underlying process directly but bypasses SCM bookkeeping (status will show `STOP_PENDING` until SCM notices).
Worked examples
Stop a single service
sudo systemctl stop nginxsudo launchctl bootout system/org.nginx.nginxStop-Service -Name w3svcsc stop w3svcForce-stop a service that has dependents
sudo systemctl kill nginxStop-Service -Name MSSQLSERVER -Forcenet stop MSSQLSERVER /yStop multiple matching services in one call
sudo systemctl stop "*.timer"Get-Service -Name "Win*" | Where-Object Status -eq Running | Stop-ServiceGotchas
- `Stop-Service` (and `sc stop`) returns SUCCESS when the SCM accepts the STOP request, NOT when the service has actually exited. The `Stop-Service` cmdlet then BLOCKS up to 30 seconds waiting for `STOPPED` status before returning; use `-NoWait` to fire-and-forget, or `(Get-Service w3svc).WaitForStatus('Stopped', '00:01:00')` for a longer custom wait.
- `Stop-Service -Force` ONLY overrides the dependent-services check; it does NOT force a kill of an unresponsive service. If a service hangs in STOP_PENDING, the only escape is `taskkill /f /pid <pid>` (find the PID with `Get-CimInstance Win32_Service -Filter "Name='svc'" | Select-Object ProcessId`).
- systemd `systemctl stop` honours the unit's `TimeoutStopSec` and ExecStop scripts. A misbehaving service can ignore SIGTERM up to that timeout — increase visibility with `journalctl -u nginx -f` while stopping. To globally bypass timeouts on emergency shutdown, `systemctl --signal=SIGKILL kill nginx`.
- macOS `launchctl stop` and `launchctl bootout` are SUBTLY DIFFERENT: `stop` halts the running instance but the LaunchAgent stays loaded — KeepAlive=true will restart it immediately. `bootout` unloads the agent definition entirely. Confusing the two is the biggest single launchd gotcha. For "really off, stay off until reboot" use `bootout`.
- cmd `net stop` is interactive — it PROMPTS for "do you also want to stop dependent services?" and the prompt blocks scripts. Use `net stop <name> /y` (auto-yes), `sc stop <name>` (no prompt, but does not stop dependents — they fail-fast), or `Stop-Service -Force` (PS, recursively stops dependents in correct order).