Added second-click-to-close feature