Setting timer to close app on back button pressed

How can I set a timer to close app on back button pressed, if i load up my app then hit back button to close it sometimes ads will popup out of app so how can I set a timer that closes app after say 5 seconds with a message that pops up saying closing app in 5…4…3…2…1…bam closed. this should allow enough time for ads to load and then app closes.

Jus create a runnable and use handler to start it. When you call the runnable just create a global boolean variable and set it to true and call onBackPressed()
Implement onBackPressed() and show ads based on your global boolean variable

I hope you understand wht i m tryng to say :wink: