add a modal stack and return a function to close the modal