fixed crash on shutdown with multiple scripts