How to prevent user to log off when there is unsaved changes in work object level

How to prevent user to log off when there is unsaved changes in work object level. When user click on log off user need to get prompt like pyDirtyCheckConfirm section. We are currently using Pega 8.6 version.

Use one custom Log off action instead of the standard direct logout. In that action, first run Pega’s built in dirty check for the current harness, and if the case has unsaved changes, show the same pyDirtyCheckConfirm popup and cancel the logout. Only continue to the normal logoff when the harness is not dirty. This works because logout does not automatically trigger dirty checking in Pega 8.6 unless you intercept it first. So the real fix is to override the Log off menu item and route it through the dirty check before calling logout.

@Sairohith Can you please help with configuration please. I have tried still having issue not able to restrict.