New dialog box closes correctly now