fix base destructor not correctly closing files