added delay and clean quitting