Trouble closing calc file from macro

I have basic macro running in base which opens a calc file with

oFile = StarDesktop.loadComponentFromURL(sFile, "_blank", 0, Array())

After reading lots of data from the file it is the supposed to be closed with the statement

oFile.close(true)

But the file is not closing.
If I edit out all the intervening lines, it works as expected.
Any suggestions why it might not work in the full macro?

Ubuntu 20.04; LO 7.2.2.2

maybe better:

'…'
oFile.store()
oFile.close(true)

Try before closing:

oFile.setModified(False)

Thanks to both @karolus and @sokol92. I tried both without success, but the problem has vanished. One is always left with the nagging feeling that this program may let one down at a critical moment. For the moment I can only hold my breath …