a function. allows execution of a function before closing the view
executes onBeginClose, and then removes the view.