There is a bug with security settings "Wake device". It is sometimes hit or miss with turning the screen back off after using it to turn it on. I have solved this problem by adding a wait for a few seconds longer than the wake device setting and then kill app secure settings if it bugs. If it works, I have another profile that kills the task if it is still running upon the display turning off.
For example:
---------------------------------------
Profile: "Wakeon" trigger = state detects prox + state display state off
----->
Task: "Wakedevice"
%Displayon1 set to 1
wake device "Screen & Keyboard Lights On", 15 seconds.
Wait 17 secs
Kill app "Secure Settings"
%Displayon1 set to 0
Profile: "KillWakeon" trigger = event display off + state variable %Displayon1 = 1
----->
Task: "Killwakedevice"
Stop task "Wakedevice"
%Displayon1 set to 0
----------------------------------------
From my observation:
While the secure settings app is executing the "Wake Device", it will override the display timeout setting. If the app bugs, the app "secure settings" seems to hang in the background and the display will not turn off. What causes this, I have not a clue. The above example has solved this issue. So if the secure settings wake device does happen to work and display turns off then it kills the task from running further. If doesn't and bugs out, then by killing the secure settings app it will let the saved system's display time out execute. So far this is working really well for me. I hope this helps someone.