Minor bug fix when closing dialog