bugfix to close dialog correctly