client throws error on close with pending messages