Seems like a fancy optimization, working with probability.

The logic in words:
If more than half the refcounts have been released subsequently, without adding a refcount in between, stop our overlay (*because we are likely shutting down*).

Actually, the release function is the only place we (can) clean this up. So maybe: In case the application does not adequately release the device but no longer uses it, to still free and clean our stuff we clean up earlier than at 0 (when the device is freed).
If presentation continues, it is recreated in the present function anyway.

Maybe analyse/test this after the PR?
Maybe we can go for a “correct” implementation, freeing on 0. I am also not sure if a device no longer in use by an application would still get `present()` calls?