Ensure correct end/close handler correct async behavior

@purplefox would you mind to review this ?
Any reason why this one is async but the one three lines below is sync?