Fix race where _ended can flop from true to false