If there are errors, report the value returned by dlerror.  Also, close the file in the co-simulation driver.