If you click the X button, the disk optimizer should finish working on the one file it is working on, update the disk directory, then stop.
The consequences of a crash during optimization depend on exactly what the optimizer was doing at the time of the crash. The optimizer moves pieces of files and updates the disk directory. If it crashes or is forced to quit, the consequences can range from nothing (it may have been just about to move something) to loss of a file, loss of a folder, or loss of the entire volume (in the unlikely event that a piece of the disk directory itself was being moved). That is why we recommend making a backup before you begin, and making sure that the backup contains what you intended it to.
You should run the Surface Scan to check the drive for unremapped bad blocks.