Just follow the tutorial I linked to before and use the newest Magisk and this patched boot.img:
boot.img
If you flash the image instead of just booting it, you modify the boot partition, changing it’s hash and breaking Android Verified Boot in the process. In that state you indeed can’t lock your system, as is to be expected.