Close or Terminate Libreoffice - through coding

Hello All,
My macro running through .ods file, When open .ODS file macro will execute and It will make another csv file which I called it “Output_file.CSV” and Output_file will close also
But then I want to close my that file .ODS file, which I has opened it for execute macro

Simple when I click on .ods file , macro should be executed and after close both file output file and yes also .ODS file

Anybody…?

Lion

After you have closed the file, as you know LO will continue to run in the background unless you tell it to terminate, the command for which is starDesktop.terminate. To create a clean shutdown, that does not later prompt for file recovery, a substantial Wait appears necessary prior to the terminate command because of an apparent race condition in LibreOffice. Your Wait may need to be longer, or it might be shorter. Thus the sequence ending with the clean terminate command would be:

ThisComponent.close(True)
Wait 400
starDesktop.terminate

Called by itself, the terminate command does generate a save prompt if the current document is modified, but the shutdown typically will be unclean due to the noted race condition.

(if this answers your question, please accept the answer by clicking the check (image description) to the left)