Modal now checks if widget is contained in a modal before removing