Panel: Allow dynamically created close buttons

This change allows dynamically created close buttons to close the panel.