Exposed the close reason in the onclose callback.