The second argument you pass to removeEventListener
has to be the function you want to remove.
You have a function expression there, so it will create a brand new function. Since it is a new function, it can't match any of the existing event listeners, so none of them will be removed.
This could work:
const x = function (e) { console.log(1); };
foo.addEventListener("focus", x);
foo.removeEventListener("focus", x);
But this won't (two different but identical functions are not the same function):
foo.addEventListener("focus", function (e) { console.log(1); });
foo.removeEventListener("focus", function (e) { console.log(1); });