Ensure correct end/close handler correct async behavior

@purplefox would you mind to review this ?