>I need to do something when the OS is going to sleep. when the app
... so it's taking longer than 20 secs for your application to
From the documentation it would appear you can't.
Can you instead re-think your strategy so it doesn't take > 20s to