Cleanup directory scan, terminate networks on shutdown.