replace exit with return and EXIT_* constant