sys.exit() is implemented by creating a SystemExit exception, so the cleanup actions specified at the end, with the exception of the try statements, are executed, and you can intercept an attempt to reach the external level.
In your SystemExit example, the following except SystemExit displayed.
source share