Maybe add a 1--2 second delay to catch any additional responses from the network? I assume the web interface just uses the gl_modem binary?

You can make it delay only when a USSD type AT code is issued.