Solidworks crashes trying to open files sequentially, when I run a macro

I am running a macro which opens an .stl file and runs something and closes it. I need to run this on about 24000 files, but when I run the macro after processing about 1300+ files, solidworks crashes. Is there any workaround for this ?

I'm using Solidworks 2018-19 education edition.

SolidworksApi/macros