Fix a segmentation fault

Fix the segmentation fault caused by clicking on the "Cancel" button of the export dialog, as in issue #249.