close an open ressource if an exception happens