OpenCV does not implement WND_PROP_VISIBLE when compiled with Gtk 2 or 3. Instead it always returns -1, which extract_otp_secrets interprets as the window having been closed. See https://github.com/opencv/opencv/issues/25346, which is marked as closed but actually still present in OpenCV 4.11.