This is unfortunately a known issue. Not all resources released when you close the file. So depending on this size of the files and your system resources you will eventually get SolidWorks to crash. For that reason we have developed a batch macro running utility called #TASK.
The utility takes care of crashes and hangs of SolidWorks and automatically restarts and continues the work if needed. Furthermore it can automatically restart SolidWorks every n-files just to free the resources (we have noticed that after some number of files the system slows down and it is better to restart).
You can run your own macros in there as well as use the one from the online library.We already have the 'Save PDF' task in there. So if you just need to convert your drawing in a batch #TASK would help but if you developing a bigger application you have to implement the events system watcher to catch SolidWorks crash/hang and restart.