Prevents controller from trying to close twice and adds additional onClose callback.