how to edit and quit by nano
Ctrl + X will quit the editor and you will be asked if you want to save your changes. If you do, press Y for Yes.
Ctrl + O should also work, since that means to save the file, but you won’t be asked “Save modifier buffer ? " because you already told nano to save.
And you need to press Enter to confirm the filename to save to.