Fixed issue when dismissing dialog