Fix linux crash due to deallaction order with keyboard and mouse handler in static scope