Fix window not disposing bug.

Previously, exiting the window generated by OpenCV seemed to only hide
the window, but not destroy it. As a result, the program would get stuck
in an infinite loop. This commit resolves the problem on Windows 7, but
needs further testing.