Fixed segfault if all windows are closed.