Bug fix: avoiding devices to be destroyed when popup menus close.