If the script needs to run at 10PM, why not schedule it with task scheduler. Then all you need to do is exit the script at 11PM.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.