<p>Sometimes, I'll have a terminal tab with <code>kubectl exec bash</code> running in it to check on a container or tail a log file.  When I shut my laptop, turn on my VPN, or just lose Wi-Fi for a second, that terminal can sometimes freeze and leave me unable to exit it without closing the terminal tab or killing the process manually.</p>

<p>I know that SSH sessions have an enter-tilda-period key combo that lets you quit in just this situation, but this doesn't seem to work for <code>kubectl exec</code>.  Is there any similar way to accomplish this in this situation?</p>

<p>It is not clear what is the root of the problem causing abnormal hang ups of <a href="https://kubernetes.io/docs/reference/kubectl/overview/" rel="nofollow noreferrer">kubectl</a> exec command.</p>

<p>Getting back to your question, you can force to drop the connection and return control of (docker) terminal
back to your hands by setting: <code>--request-timeout=&lt;value&gt;</code> to the kubectl command line:</p>

<p><code>kubectl exec --request-timeout=5s bash</code></p>

<p>It is possible to force termination of kubectl exec by sending -9 signal using kill command.</p>

<p><code>kill -9 $(pidof kubectl)</code></p>
