Fix bug which caused websockets run loop to exit