Fix usage of onerror in the onclose section

Update the example to 
- use `onclose` and not `onerror`
- remove the `err` argument passed to the callback