Improved reporting of stack and serialization run-time errors.

These errors can be triggered by __tostring methods that may be failing at
run-time. As those are called from the serializer used in the debugger,
any errors from these calls need to be reported back to the application.
Updated os.exit() call in local console to exit gracefully.