Basic error on close

Trying to close a Basic routine using a module (I think supplied by @JohnSUN ) and I get an error. Can anyone please decipher the message?

Sub closeOOo
  Dim oEnum
  Dim oDoc
  oEnum = StarDesktop.getComponents().createEnumeration()
Do While oEnum.hasMoreElements()
   oDoc = oEnum.nextElement()
   If HasUnoInterfaces(oDoc, "com.sun.star.util.XCloseable") Then
   oDoc.setModified(False)
   oDoc.close(True)
  Else
   oDoc.dispose()
   End If
Loop
StarDesktop.Terminate()
End Sub

Message:
BASIC runtime error.
An exception occurred
Type: com.sun.star.util.CloseVetoException
Message: Controller disagree …

Hello,
Do not understand wanting to close a Basic routine. The code you present appears to be for closing LO but will not close an open Basic IDE. See discussion here > Close OOo from a macro

No, this is not my code. This was published by @alf50 back in 2010. And then it didn’t work…

Sorry, John, but the routine does work fine and my problem is sorted.

Could be brute force (needs to be further tested)?

' Close BasicIDE window (if opened).
Sub CloseIDE()
  Dim oDoc As Object
  For Each oDoc In StarDesktop.Components
    If oDoc.supportsService("com.sun.star.script.BasicIDE")  Then  
      oDoc.CurrentController.frame.dispose
      Exit Sub
    End If  
  Next oDoc
End Sub