Close Flyouts with external click (makes #965 obsolete)

Due to my failure in not being able to rebase #965 I have created a new pull request on a new branch.

Fixes #962