fixed end dialog

fixed end dialog (thanks to CSL)