When WindowServer crashes (or you force-quit it), macOS drops you back to the login screen and, once you log in, relaunches every app that was running. The "Reopen windows when logging back in" checkbox doesn't help here: you never see the logout dialog, so it never gets a say.
lock-saved-apps.sh stops this by emptying the files where macOS keeps the "apps to relaunch" list and making them immutable. macOS can't save the list, so there's nothing to relaunch.
Not affected: login items (System Settings > General > Login Items) still start as usual.
Tested on macOS 27. It also covers the location used by earlier releases.