Example refined to illustrate OnClose call with extended connections.