Fixed warning when trying to close resource in destructor of constructor failed