shell: Fixed a crash caused by GUI functions getting called from non-GUI threads.