Added beforeClose hook function for views
View.close() triggers a 'close' event at the end