IMO that's anti-pattern / code smell, in most situations.
For cli tools, on the other hand, there are definitely legitimate cases for exiting early.
def main()
blablabla
if foo:
return bar
...
return 8
if __name__ == “__main__”:
os.exit(main())
Of course that’s just my advice / opinion / preference, other ways are valid as well...