I wonder if there is a racing condition here - what if the script program shuts down, and we catch the exception, but the throwable callback is registered after the consumer thread (i.e. the main thread) is done?

When the script program shuts down, does the main thread get any error?