Your modular view controller has a method -viewDidDisappear:that is automatically called whenever the view is removed from the screen. You can override this method in your modular view controller to do whatever you like.
In addition, you might consider using the method -viewDidAppear:in a view controller whose view is detected when your modal view disappears.