# Is there a way to make code 'shut down' or stop in the middle of the game?

**URL:** <https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038>\
**Category:** Help\
**Created:** [June 1, 2024, 4:42am UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038 "2024-06-01T04:42:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Galcake](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/galcake/32/16060_2.png) [@Galcake](https://forum.makecode.com/u/Galcake)\
**Post date:** [June 1, 2024, 4:42am UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038/1 "2024-06-01T04:42:04Z")

</div>

![Screenshot 2024-06-01 at 1.51.12 pm](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/06f6552de1f3bcfde83b3726558e01d5746e8f9d.png)

I’ve made code for a boss fights first phase and the attack cycle they use. When it’s first phase reaches zero health, it stops attacking, which is great. The only issue is that if it hasn’t gone through it’s full attack cycle it will always finish it’s attack cycle before stopping. I’m wondering how this can be fixed, because it’s stopping me from developing the game further and I don’t know any possible solutions.

---

<div class="post-metadata">

**Author:** ![Terminator](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/terminator/32/14612_2.png) [@Terminator](https://forum.makecode.com/u/Terminator)\
**Post date:** [June 1, 2024, 5:51pm UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038/2 "2024-06-01T17:51:23Z")

</div>

Well, this my take on it.  
It may be tedious but it _should_ work

 ![Screenshot 2024-06-01 141943](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/14330b2f96ba2e971af01d2b2b44ad35f96b0061.png)  
Each time it tries to make a move, it will check the value of “BeeOneHealthBar”. If the first stage is over, the attack will not be executed.

---

<div class="post-metadata">

**Author:** ![Timothy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/timothy/32/15005_2.png) [@Timothy](https://forum.makecode.com/u/Timothy)\
**Post date:** [June 1, 2024, 5:51pm UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038/3 "2024-06-01T17:51:31Z")

</div>

Hi @Galcake  
Are you using micro:bit???

---

<div class="post-metadata">

**Author:** ![Blobbey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blobbey/32/20831_2.png) [@Blobbey](https://forum.makecode.com/u/Blobbey)\
**Post date:** [June 1, 2024, 5:56pm UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038/4 "2024-06-01T17:56:23Z")

</div>

I think the `break` block would work.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3513b769a4ebec987eb46f7dddbdcd50737332b3.png)

---

<div class="post-metadata">

**Author:** ![Galcake](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/galcake/32/16060_2.png) [@Galcake](https://forum.makecode.com/u/Galcake)\
**Post date:** [June 2, 2024, 4:48pm UTC](https://forum.makecode.com/t/is-there-a-way-to-make-code-shut-down-or-stop-in-the-middle-of-the-game/29038/5 "2024-06-02T16:48:48Z")

</div>

Yeah, I did something like that inside of the attack functions themselves and it works like a treat.
