Can you put the `close` call in an `ensure` block so that we don't leak handles if the `report_event` call fails.