Do not run any events if filterdns is exiting. Also simplify when a command is executed to make cleaner and more readble the code