added os.sync() before sys.exit() to make sure the changes to syslog are
written on termination