Working on closing the dialog box when reached the end of dialog.