try to call dispose when exiting