Intergrate quit into main operation logic