listen for `close` event instead