pub fn shutdown()Expand description
Stop every live capture ahead of the process’s exit, and raise the consumer-gone gate first so no detached thread calls a sink again.
An active recording is finalized first, so its last buffered MP4 sample is flushed and its
own capture stops through the normal path. The cursor sinks (the X11 monitor’s and a
never-applied compositor stash) are dropped, every X11 capture’s stop flag is set and each
thread waited for (bounded): it joins its own encode thread on the way out, dropping the
NVENC/CUDA session, and a process exiting while that drop is in flight segfaults. A live
Wayland capture is stopped over the command channel and the calloop waited for the same
way through a barrier. A brief grace sleep lets the stops be observed. The Python bridge
runs this from atexit; a Rust host calls it before main returns.