Add destructor ensuring `close()` is called