Catches error and close from web socket