handle saving untitled documents on close