fix up host command to send `bye` message in `beforeunload`; rearrange order (related: #105)
hook up events (#44)