Escape a process (for-loop) upon button-click


in my shiny-app I start a process with an actionbutton (eventReactive), this triggers a for loop that may run a while, when there are many datasets included.
So I planned to setup an escape-function, basically a second button that can be used to stop the process.
For this the "break" feature can be used, it works well when I hardcode a condition (e.g. the 10th element in the list that is called by the loop)
However I do not manage to link this to the button.

The button is created with "actionButton("plot_abort", "Abort!"),
so I tried to include
if (input$plot_abort != 0) {
within the the for loop (as the button should be 0 when not pressed?)
But this isn't working. I would guess it is not evaluated anymore once the loop is started.
Then I included the abort in the observeEvent
"observeEvent(c(input$Run_Plotting, input$plot_abort), { ... } )" but this doesn't help, too.

Any ideas how I can solve the issue?


You may want to check this blogpost.