core: Remove error and close handlers before ws restarts.