How to break/return/exit out of "When Button clicked" block

This question has been asked many times in the past like 2019/2020 but does not seem to have a solution. Now with Thunkable X do we have a solution? I don’t want to exit out of the app just release the button control in the middle where ever I want. Please help me out.

Can you give an example of what you mean? The “When button clicked” block is triggered when you first click/tap a button and it runs the code inside the block. What are you wanting it to do differently?

1 Like

Please note this is just give you an idea not a working app:

Please see the breakout inside the count loop. Now suppose I want exit out of the “when block” at the juncture there is no easy way out. If there are nested if blocks inside a count block then breaking out of the when block is a real challenge. “When block” is like a function call in C. In a function call in C we can put a “return” anywhere and get out. I was looking something like that here.

1 Like

Now I understand what you want. There is not a built-in block that exits out of an event block so you would have to structure your blocks differently.

1 Like

Yes that is what I have been struggling. It seems in classical Thunkable they had something like this:
that was my one small hope. I guess there is no easy way out. Thanks Tatiang.

I will alert all thunkable staff about this

Or maybe just spam multiple variable and blocks at the same time or lag the system so much that the Thunkable app engine crashes. I’m sure it won’t work. It’s your second hope before the final one.

1 Like

I guess you are joking :slight_smile: Some one suggested Navigate to Screen2 and then Navigate back to Screen1 none of them worked.
All Thunkable have to provide is “return” module which should work from anywhere and return to the screen of choice. Like this:

1 Like

yeah but lets wait

Hello @anandavardhana57zwwl ,
This feature is not available, but this is a good suggestion!
I’ll pass it on to the team.
Why do you need to close the app?
Have you tried to use the open link block?
assets_-LAn5scXl2uqUJUOqkJo_-LAn5wecEraNWaG7Ig2g_-LAn67AX3DtlqidVUA7T_blocks-control-✕-fig-6 (1)

1 Like

open link will just take me to the link my app is where ever it was earlier. I want the app exit from from wherever I want, print out an error message and give back the control back to the user.
In the above case it should break and user should be able to click the button again. If Thunkable can implement the “break” from the any block that would be very nice. Right now we can break away from a loop only.

That’s what I said, you can crash the app, then it will stop responding. If you’re on android it will say APPNAME isn’t responding. Do you want to close it? Say ok. I’m not sure, but you can find ways to crash the app, maybe one of your only options.
I understand we need a simple block to exit app, but without it, this is your only option:

This is not at all the same thing as @anandavardhana57zwwl is asking for, though. They want a way to break out of a function… not exit the entire app. There are ways to work around that but I can see it being useful in some cases.

1 Like

Exactly, thanks Tatiang.
Hi afnanfozailcw8, I dont want to crash just exit out meaning out of the “when button is clicked” so the user can do what ever they want. To give you a C++ analogy. Imagine the “When Button click” as function call from which user can break out anytime.

main() {

func1() {

// In this function I can use the return() call any where and immediately 
   return back to main


I don’t get it clearly, but are you saying to end a function? break out of loop from function?
Try rewording if you can

Imagine a complicated nested loop like this. So I want break out of the control of the button at the if(true) point. Right now Thunkable has no easy way to do it. My wish is to have a block called [ButtonBreak]. So that ButtonBreak module will go in the do slot and when the If condition is satisfied just get out the button control. Please note I am noy exiting out of the app, I am not closing the app. The user gets the control back.

So basically you can just do this, but I’m not 100% sure if it works or not. If you don’t want any repeated action then you may not want to try this.
Screenshot 2023-02-14 9.02.09 PM

Yes this might work but I want a more elegant solution. The one I am using now breaks anywhere. I want this kind of mid execution break(). Making it a function() is the way I use. Tatiang had given some hints saying do some restructuring that is what I did, so until Thunkable comes up with a way to break I will do this workaround. Thanks for your comments.

1 Like

What if you make the if true into if else if and break out of loop? I’m also not sure because what if it breaks out of forever?

…so until Thunkable comes up with a way to break I will do this workaround.

And yes, I also wish Thunkable comes up with a solution or adds a new block. Thanks for that.

1 Like