Added specific code for OSX closefunc