Fix free error at exit