ensure system exit (looping foreground thread may cause shutdown hang)