Fixed bug on shutdown: network connections must be closed before storages, to reduce the probability of deadlock