You can close the Find and Replace dialog at any time using the Close button. Any changes you have made up to the point at which you close the dialog will be retained.
A subsequent Undo command (<Ctrl + Z>) unwinds all the selective and transactional changes made from a Replace session as a single action: i.e., whether you made a single change, multiple individual changes or used Replace All, the changes you made in a single Replace session will be reversed by pressing Undo once.