shutdown now sets a flag to terminate the main loop