Question: How to ensure ModuleUnload is called when closing Maple?

Hello, 

I'm working on a Maple package that manages external processes via TCP connections. I'm using ModuleUnload for cleanup, but I need to better understand how it behaves during Maple termination.

The issue:
- I have a module that manages external processes (via TCP connections)
- I implemented ModuleUnload to kill these processes when the module is unloaded
- ModuleUnload works perfectly when using 'restart' 
- However, when closing the Maple window, the external processes remain active

Investigation:
Using 'lsof', I observed that:
   - When Maple closes, it properly closes its TCP connection (goes to CLOSE_WAIT state)
   - But the external processes remain active

Questions:
1. Is this the expected behavior of ModuleUnload during session termination?
2. Are there alternative approaches to ensure cleanup when Maple is closed?

Any insights or suggestions would be greatly appreciated!
Thanks!

Please Wait...