Free memory when uncaught error