Is there a scripting possibility or application, free or commercially avaible, that would allow me to set up windows to close a partuicular application before it goes to sleep mode?
You can create a Scheduled Task in Windows' Task Scheduler.
There is an "When a specific event is logged" trigger available. The event you need to trigger on is in the "System" log with the Source "USER32" and Event Id 1074. This event is logged whenever the system shuts down or goes into hibernation.
As for the shutting down a particular application you add an action the the Scheduled Task which starts the "taskkill" program. With
as argument it will shut down the ExecutableName.exe. You may need to add a /F switch to make it force the program to shutdown (instead of just asking nicely).
This is just a addition to Anders J's answer...
On Windows 10 in System log I right clicked on Event Id 42 and added task (bat script basically) with taskkill command from my comment...