modal close order of operations fixed