Fix animation race and hang on socket close.