Fix for script error on pressing a close button

that removes the button pressing it.