Removed object creation when clicking a button to close a dialog.