Fix to close the connection