undo removal of onclose for websocket api compattibility