Overlay close conditional logic. Fixes #199