Fix OS X show/hide/close bug