Fix for sys not defined on exit