Make sure modules shut down properly
Right now, it doesn't look like modules are shutting down properly. This means that there's a potential to lose work done in a module right now since the module gets shut down by the OS if the main thread closes first.
Edit: Looks like I made a mistake debugging.