added safe quit