Fix a segfault when removing a menu while iterating over them (#210).
Replace a C cast by a static_cast.