Updated the example, to show how to handle an 'exit' message in JS.