fix more TypeErrors when closing the connection