fix for #133 -- data loss when closing, saving, cancelling new document