What about if I'm stuck in a bootloop and cant remove pin?
Or actually I could probably remove it in TWRPs file manager by going to /data/system and remove the files that end in the .key extension and any files that have “locksettings” such as Gatekeeper.password.key, gatekeeper.pattern.key, settings.db, locksettings.db-shm and locksettings.db-wal.
I'm not sure this is, or should be necessary but the only times I'm able to actually restore correctly is by first backing up my internal storage as to not lose anything. Then do factory reset and format data, "yes" and reboot the device. Let it boot up to the ROM, and add back my internal storage which contains my TWRP backup, reboot to the TWRP recovery and restore. And then it succeeds with the needing to do a reboot after the first initial boot.