Fix a bug that leaves connections open.