remove exit calls and add ifdef for WINDOWS