Deal gracefully with R websocket close

Before httpuv we would not receive wsClient.onclose event during graceful
session end (i.e. browser reload). I believe this may be because the
websockets package did not send a close frame back to the client when one
is received, whereas httpuv does. To detect when a close is graceful, we
see if the sockjs connection has already closed. Without this check, the
appWorkerHandle (which is already null) is accessed which causes the
nodejs process to exit.