Fixed segfault when user clicked red X to close app and wanted to save current file