Updated quit function