Properly close connections when done upgrading