refs #5278 by throwing the event after removing the view we prevent that some cleanup work like clearing all tables is visible when closing a window. I hope this does not introduce any side effects or memory issues