Fixed shutdown bug when modules were not initialized.