Modal does not hide

Hello,

I am using this code to show and then hide a modal window, but most of the time does not work:

<form is="dmx-serverconnect-form" id="serverconnectform1" method="post" action="dmxConnect/api/test.php" autosubmit="true" dmx-on:start="modal1.show()" dmx-on:done="run({condition:{if:`((serverconnectform1.data.api1.data.verbose_msg == \'Test message\') || (serverconnectform1.data.api1.data.response_code == 1))`,then:{steps:{run:{action:`modal1.hide()`}}},else:{steps:{condition:{if:`(serverconnectform1.data.api1.status == 204)`,then:{steps:[{run:{action:`modal1.hide()`}},{'bootbox.alert':{message:'You are making more requests than allowed. Please wait for a minute before using the tool.',title:'Request rate limit exceeded',buttons:{ok:{label:'OK'}}}},{run:{action:`browser1.goto(\'testpage\')`}}]},else:{steps:{run:{action:`serverconnectform1.submit()`}}}}}}}})">

It seems correct to me, so I do not know why sometimes it works but most of the time it does not.

Sometimes I see this message in the browser console:

[Violation] Forced reflow while executing JavaScript took 32ms

However, even if I do not see it, sometimes the modal does not hide.
The conditions are also valid and correct.

I put a big delay on the top of the flow and now it works.
Probably it is because of multiple concurrent scripts running together.