fixed dialog box so it closes after finishing