Added lock for stopAll()