<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; 4.6</li>
<li>Operating System / Platform =&gt; Fedora 36</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">After running imshow, using cv2.waitKey(0) does not close the window even after the user closes the pop-up window as the documentation suggests. Rather, the pop-up window of the image closes, but the terminal running the python file never quits. Basically, only closes pop-up, but doesn't quit the script. (since the code is still running the waitKey(0), user cannot exit the file using exit() either)</p>
<h5 dir="auto">Steps to reproduce</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import cv2

img = cv2.imread(&quot;rock.jpg&quot;)
cv2.imshow(&quot;The Rock&quot;, img)
cv2.waitKey(0)
cv2.destroyAllWindows()"><pre class="notranslate"><code class="notranslate">import cv2

img = cv2.imread("rock.jpg")
cv2.imshow("The Rock", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
</code></pre></div>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.5.3</li>
<li>Operating System / Platform =&gt; openSUSE Tumbleweed</li>
<li>Compiler =&gt; gcc 11.2</li>
</ul>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">Build OpenCV with Qt backend.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="cmake .. -DBUILD_LIST=highgui -DWITH_QT=ON -DWITH_GTK=OFF -DHIGHGUI_ENABLE_PLUGINS=OFF"><pre class="notranslate"><code class="notranslate">cmake .. -DBUILD_LIST=highgui -DWITH_QT=ON -DWITH_GTK=OFF -DHIGHGUI_ENABLE_PLUGINS=OFF
</code></pre></div>
<p dir="auto">Run minimal program:</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &lt;opencv2/highgui.hpp&gt;

int main()
{
    cv::Mat img(200, 200, CV_8UC1);
    cv::imshow(&quot;img&quot;, img);
    cv::waitKey(0);
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/highgui.hpp<span class="pl-pds">&gt;</span></span>

<span class="pl-k">int</span> <span class="pl-en">main</span>()
{
    cv::Mat <span class="pl-smi">img</span>(<span class="pl-c1">200</span>, <span class="pl-c1">200</span>, CV_8UC1);
    <span class="pl-c1">cv::imshow</span>(<span class="pl-s"><span class="pl-pds">"</span>img<span class="pl-pds">"</span></span>, img);
    <span class="pl-c1">cv::waitKey</span>(<span class="pl-c1">0</span>);
}</pre></div>
<p dir="auto">Close the window though close button, <code class="notranslate">waitKey()</code> does not return.</p>
<h5 dir="auto">Issue submission checklist</h5>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I report the issue, it's not a question

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I checked the problem with documentation, FAQ, open issues,<br>
forum.opencv.org, Stack Overflow, etc and have not found solution

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I updated to latest OpenCV version and the issue is still there

</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> There is reproducer code and related data files: videos, images, onnx, etc

</li>
</ul>