Indeed the Browser's "On back button" could be your solution, even if it seems quite restricted indeed.
It might be worth to check out within CocoonJS' plugin itself if they don't have a "On exit" condition you could use.
But to be fair, it's likely that the condition your are looking for only happens when exiting the application. And so, your text would only be displayed an instant before "disappearing" along your closing application.
Think about that before spending too much time looking down for this.