Fix shutdown hanging issue when remote DBs are disconnected