As with vi, emacs keeps track of whether there have been changes made to any buffer connected to a file. If changes are pending, emacs does not want to let you exit. But in general, the command to exit emacs is C-X C-C (Control-X followed by Control-C). Saving the contents of the current buffer to disk is accomplished with C-X C-S.