Bug fix in quit method