Only add uncaughtException listener when API methods are called

Instead of adding the `uncaughtException` listener whenever the `tmp.js` module is required, the listener could be registered when one of the exported methods are used.  Listeners could then be unregistered after API method callbacks are called.

Without this change, `tmp.js` is [frequently attributed](https://www.google.com/search?q=tmp.js+error) as the source of uncaught errors.