Fix menubar display on Windows/Linux

Avoid potential race condition