System.stop(1) does not return code to shell

How do you build and run that escript? Are you using a shell wrapper around it?

Can you perhaps provide a minimal project in GitHub that reproduces the issue? I never experienced any problems.