Skip to content

bSafeExit (TerminateProcess) disrupts standard shutdown sequence and prevents plugin cleanup #92

@cyfewlp

Description

@cyfewlp

Description I’ve noticed that when this mod is installed with its default configuration, other SKSE plugins (including my own) fail to execute their standard shutdown logic. Specifically:

  • The WM_DESTROY message is never received by the window hook.

  • Standard DLL unloading procedures are bypassed.

  • Global destructors and RAII cleanup logic (e.g., static smart pointers) are not triggered.

Findings After investigating the configuration, I identified the cause as the bSafeExit setting. It appears this feature utilizes TerminateProcess to end the game. While this effectively prevents the "Infinite Loading on Exit" hang, it does so by killing the process abruptly, which prevents the OS from performing a clean teardown of the process threads and loaded modules.

The Impact on the Ecosystem Relying on WM_DESTROY or RAII for data persistence and resource management is a standard and reasonable practice in C++ development. By bypassing the shutdown cycle:

  1. Data Loss: Plugins that save configuration or state data during the exit phase will lose all unsaved changes.

  2. Resource Leaks: External handles or file locks may not be released properly.

  3. Compatibility Issues: It forces other developers to overhaul their entire timing for cleanup just to accommodate this specific "fix."

Suggested Change I personally believe that using TerminateProcess by default is not a "safe" or sound design choice for a general-purpose utility.

Expected Behavior

  • The bSafeExit setting should be set to false by default.

  • This feature should be an "opt-in" for users who specifically suffer from exit hangs, rather than a global default that breaks standard plugin lifecycle expectations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions