Custom PlayerController does not keep the cursor locked in middle?

I wanted to use a custom PlayerController to be able to move the cursor freely and click on widgets with no problem, but now I want to bring the cursor back to the middle of screen. How do I do that?

I tried
SetInputMode(FInputModeUIOnly());
SetInputMode(FInputModeGameOnly());
but they do not lock the cursor to the middle (I’m still able to move the cursor freely).