Remove the connection cache even though the workspace deletion failed

Also make the connection close conditional only when it is not closed already.