Fixed the segmentation fault during shutdown

It fixes the segmentation fault that occurs during shutdown of mangosd.