Context Exit
Tell the model it's done, it can unload now
- value
- passthrough
- TRUE
- FALSE
Some ComfyUI nodes give you a should_unload input, and what you do with it determines whether your VRAM churns or coasts. XJContextExit is the "we're done here" end of that conversation. It's a passthrough node whose whole trick is emitting the boolean you wire to a model's should_unload input when you want it to release its resources.
The intended pattern comes straight from the node's own description: a heavy segmentation pass (SAM3 is the canonical example) where you process several items back to back. Keep the model resident for the whole run, then tell it to unload once at the end. That's the difference between loading and unloading a multi-GB SAM model once per item, or exactly once per workflow.
How it works
There's no logic to speak of - and that's the point. XJContextExit takes any value you give it (value, optional), passes it through untouched, and additionally emits two constant booleans: TRUE and FALSE. In the "context exit" sense, the node's description tells you exactly which one to use: connect the TRUE output to should_unload at the end of a context so resources are released. FALSE is there if you need a literal false somewhere - sometimes wiring a constant beats hunting for a Boolean node.
The passthrough output exists so the node can sit in your data path without forking it: your image or whatever else flows through while the booleans ride alongside. Nothing is modified, no state is kept.
The inputs and outputs
value(optional, any type) - what gets passed through. Leave it unconnected and the node still works purely as a boolean source.- Outputs:
passthrough(any type),TRUE(Boolean),FALSE(Boolean).
The pairing matters. This node is the exit half; the pack also ships XJContextEnter, which is the same thing but with the semantics flipped - you connect its FALSE output to should_unload to keep resources loaded while you're inside the context. Enter at the start, Exit at the end, and the model's residency becomes explicit and visible in your graph instead of implicit and annoying.
Installing it
It's part of ComfyUI-XJNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/alexjx/ComfyUI-XJNodes
then restart ComfyUI (or install via ComfyUI Manager, searching ComfyUI-XJNodes). No models, no dependencies beyond stock ComfyUI.
Common issues
The usual failure mode is not understanding what you're wiring: if you connect TRUE to should_unload at the start of a context instead of the end, you'll unload the model right when you wanted it loaded, and the next item pays the reload cost. Also remember this is a passthrough with no validation - if the downstream node expects a specific wiring, the node won't stop you, it'll just pass True through and let you debug it. It's a small, single-purpose tool, exactly as boring as it should be.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| valueopt | * | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| passthrough | * | — |
| TRUE | BOOLEAN | — |
| FALSE | BOOLEAN | — |