Fixed possible segmentation faults in StopAll()