fix errors at exit