Closing assemblies and parts by MACRO

I had wrote a macro for creation of STEP files from directory content

The macro read directory content save the names of drawing files then it looks for parts and assemblies with identical names, the parts and assemblies then opened and SAVEAS is used to produce a STEP file

After the STEP creation the MACRO try to close source (*.sldprt, *.sldasm).

Using

Set Part = Nothing

swApp.CloseDoc FileSNames(i)

For some reason the MACRO closes only parts but not assemblies

In  a case of many drawings in directory the MACRO stuck

Does MACRO can use another commands for closing files>

SolidworksApi macros