Android 6.0 update - System UI not working
When this type of problem happens (I've seen it happen more than once where the unlock code stops working).  Go to Google's Android Management and change the code.  This has cured the problem twice for my clients.

There are a number of ways to get to Google's Device Manager.  One ways is:

http://play.google.com -> Click on the Gear icon at the top right corner of the screen -> Click on Android Device Manager -> Login -> Select your target phone (if you have multiple devices) -> click on Lock.  Follow the prompts to change/set your lock code.

So far this has worked to resolve the issue.  I'm not sure if something specifically has to be done to enable this feature, but since you are experiencing problems, you might consider testing the steps when you're not experiencing the immediate problem so that you can verify that it will be available the next time next time you need it.