How to activate/deactivate PointerLockControls?

I managed to do it like this, but it is a bit hacky:

  setTimeout(() => {
    pointerControls.current.unlock();
  },100);

(This was helpful: Unable to use Pointer Lock API)