Better dialog closing