I think you need to modify the question, because DavidPostill already answered what you need.
Terminate the line program before sleeping seems to be the obvious
answer. – DavidPostill Feb 2 at 10:41
@DavidPostill Yes, I did that. I use quit the Line program before
manually go to sleep mode but if computer go to sleep mode
automatically the Line program will not terminated. :) – vee Feb 2 at
14:37
In theory you can schedule a task right after the sleep event. I am not sure whether it would work, but it's worth a try:
- Input “Task Scheduler” in search box and press Enter
- Click “Create task…” on the Task Scheduler---Action
- Go to Triggers, create new triggers
- On “Begin the task”, select “On an event”
- Select Log to “system” , set “Source” to “Kernel-Power” , Event ID
is “42” and click “Ok”
- Go to “Actions” and create a new actions
- You can select “Start a program”, “Send an e-mail” and “Display a
message” on action as you need. If you want to mute sound, a script
may be needed.
Some reference is this Microsoft-link.
So you need to schedule a task right after a system / kernel power event. The id of the sleep event is 42. You need a small script, which closes your application, probably something from WSH or a batch script.
If the event 42 is too late for closing the application then there is still hope. According to this there is no before sleep event in the kernel power api: https://superuser.com/a/601685/105936 , but you might find something similar by investigating further the links in the answer.
So it is not impossible to close the application automatically, but you have to work on it.