Stops the generation immediately when using the "Maximum number of tokens/second" setting
diff --git a/modules/text_generation.py b/modules/text_generation.py
index a3755c10a7..db897e66b4 100644
--- a/modules/text_generation.py
+++ b/modules/text_generation.py
@@ -96,7 +96,7 @@ def _generate_reply(question, state, stopping_strings=None, is_chat=False, escap
                     last_update = cur_time
                     yield reply
 
-        if stop_found:
+        if stop_found or (state['max_tokens_second'] > 0 and shared.stop_everything):
             break
 
     if not is_chat:

Hello,

When using the "Maximum number of tokens/second" setting, if you start to generate and then press the "Stop" button, it doesn't really stop immediately, it's due to the fact that it's waiting for the whole generation (the one with the full speed) to display all its tokens.

This simple code fixes that and makes the Stop button an immediate stop in this situation.