I apologize for the delay with the reply.
Please, try to use the awaitRedraw() helper:
Like:
The common logic in your case: you should not hide the control until some other operation with that control is not finished yet. So, it is need to use the awaitRedraw() to wait till that operation finishes