Use this macro to start a module shutdown function.
This shutdown function is called before a module is unloaded from the process space. The function is similar to besSUB_FINISH. That function is called when the interpreter finishes. When there are many interpreter threads in a single process that uses the module the function besSUB_FINISH is called each time an interpreter finishes. The function besSUB_SHUTDOWN is called only once, before the interpreter unloads the extesion from memory.
The difference between besSUB_SHUTDOWN and besSUB_PROCESS_FINISH is that besSUB_SHUTDOWN is called by the interpreter, besSUB_PROCESS_FINISH is called by the operating system. besSUB_SHUTDOWN can access the support functions because it gets the pSt argument, besSUB_PROCESS_FINISH can not access these functions.
When a single thread interpreter finishes it first calls the function besSUB_FINISH to unload the module and after that it calls besSUB_SHUTDOWN.
This is not an error if a module does not implement these functions.
The function should return COMMAND_ERROR_SUCCESS if the module has no remaining activity and is ready to be unloaded.
The function should return COMMAND_ERROR_STAYS_IN_MEMORY if there are unstopped threads that use the module code. In this case unloading the module would cause segmentation fault that would interfere with the still running shutdown procedures. In that case the module is not unloaded by the program, but only when the process finishes by the operating system.