Don't show msgboxes outside of the GUI thread

Fixes #511