The switch is not necessary, an if-statement would work just as well. I was just thinking that a switch case statement would be nice if more onClose options were to be added.