Corrected memory leak in quit() function