diff --git a/ChangeLog b/ChangeLog
index b9bb8a575..bf7f27edf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-09-10 Peter Stephenson
+ * 36468: Src/hist.c: Infinite loop if we tried to exit from a
+ Zle widget but the lexer thought the current lexical expression
+ needed finishing.
+
* 36460: Test/E01options.ztst: Discard benign error on failure
to write to pipe with no one reading.
diff --git a/Src/hist.c b/Src/hist.c
index 75e809c48..9c42d85c9 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -390,6 +390,12 @@ ihgetc(void)
{
int c = ingetc();
+ if (exit_pending)
+ {
+ lexstop = 1;
+ errflag |= ERRFLAG_ERROR;
+ return ' ';
+ }
qbang = 0;
if (!stophist && !(inbufflags & INP_ALIAS)) {
/* If necessary, expand history characters. */