That was my original fix too. But then I wondered about a race condition where the module gets unloaded before grid_loading = 1 is executed?
In theory maybe, but that's how most of the other modules with a "running" state work. If we need to resolve that, we should add some kind of delay or to the module_tick_unloader process.
I think in practice the window for problems there is nanoseconds, where the original grid loading could take tens of milliseconds and involved blocking IO calls that would yield to other tasks.