fix exit after fork

detach and call exit with safe exit code