fixed bug in quit handling code