Flyout close fix

Fixes #1487.