fix potential crash on exit when closing the Display window