Fix a window leaked bug