SaveWorkflowAndShutdown
Let the machine power down when the queue empties
- trigger
- passthrough
- status
If you've ever queued a long batch and gone to bed hoping the render finishes without the machine idling all night, this node is aimed squarely at you. SaveWorkflowAndShutdown sits at the end of your graph, watches the queue, and when the last job completes it saves a copy of the workflow and powers the PC off. Set it, queue, walk away.
The name is the spec. It's a "I want this to be done and the machine off when I come back" convenience node, and nothing more - which is fine, because that's a genuinely annoying problem to solve manually with a scheduler.
How it works
Wire any output into trigger (it's an any-type input, so anything can feed it and it passes straight through to passthrough). On each run the node asks the prompt queue how many jobs remain. When this is the last job, a frontend hook calls the pack's /save_and_shutdown/trigger API route, which:
- Confirms the queue is actually empty (it re-checks server-side - if other jobs remain, it aborts and waits).
- Saves the workflow - either overwriting the currently loaded file (
Overwrite Existing Filemode) or writing a new timestamped file into ComfyUI's output folder (Save as New Timestamped Filemode) with yourfilename_prefix. - Sleeps
delay_seconds(default 60, min 10), then runs the OS shutdown command:shutdown /s /t 1on Windows,sudo shutdown -h nowon Linux/macOS.
The status output tells you which state you're in: disabled, waiting with N jobs queued, or triggering shutdown.
Settings
trigger- any connection; purely to place the node in the graph.enabled- must be True or nothing happens (the node defaults to disabled, which is the safe default).delay_seconds- the shutdown countdown, so you can cancel.save_workflow,save_mode,filename_prefix- whether and how the workflow is saved first.- Outputs:
passthrough(your trigger value, unchanged) andstatus(a readable string).
The honest warnings
sudo shutdownis the fragile part. On Linux/macOS the command needs root without a password prompt, or it silently fails at the end - you'll see the error in the ComfyUI console and the machine stays on. Set up passwordless sudo for the shutdown command if you actually want this to work.- Your only cancel is the delay window. The README is blunt: "if you want to interrupt, cancel comfyui's process." During the countdown, kill the ComfyUI process and the shutdown aborts. After that, the OS takes over - your saved workflow is on disk, but unsaved anything-else is gone.
- It saves the workflow JSON, not your generations. Images are saved by your SaveImage nodes as usual; this node only guarantees the workflow graph is on disk so you can rebuild the run. Set
save_workflowoff and you get shutdown with no autosave. - Queue-counting edge cases. It checks "jobs remaining" including the current one, so a workflow that queues more items mid-run (an "efficient loader" or a loop that re-queues) will see this as not-the-last-job and wait. That's correct, just don't expect it to force a shutdown past a re-queueing graph.
Install
ComfyUI Manager (search "Santodan"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Santodan/santodan-custom-nodes-comfyui
Restart. No dependencies, no downloads. Test it once with enabled on and a tiny delay_seconds while you're in the room - shutdown nodes deserve a dry run.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| trigger | * | — | |
| enabled | BOOLEAN | false | — |
| delay_seconds | INT | 6010–600 | — |
| save_workflow | BOOLEAN | true | — |
| save_mode | COMBO | 2 options: Overwrite Existing File, Save as New Timestamped File | |
| filename_prefix | STRING | workflow_autosave.json | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| passthrough | * | — |
| status | STRING | — |