update quit function to terminate program iteration