Hello Paul. Thank you very much for your help. The link was very useful to me. After reading and reading, I found the line I needed there.
The solution is to add line
B4X:
Wait For Msgbox_Result (Result As Int)
after the Msgbox line. It looks something like this:
B4X:
If EditTextPasswordIn.Text = Pass Then
PanelMain.Visible = True
Else
MsgboxAsync("NO VALID", "Password")
Wait For Msgbox_Result (Result As Int)
ExitApplication
End If