In whichever mode you are, press ESC to enter the command mode. Then type :q. If you made changes in a file before, you will have to save the changes by typing :wq. If you do not want the changes to be saved, type :q! to exit. Congratulations, you mastered one of the most difficult tasks in the world ;-)
Opening csv files in a spreadsheet program is problematic, because these applications may introduce styles or hidden characters into the files and harming your data, which needs precision, not style. A text editor like vim (or VSC) handles your data like plain text and won't make any unwanted changes (Anthony DeBarros, Practical SQL, 2nd edition, 2022).
ESC + :q quit
ESC + :wq save & quit
ESC + :q! quit without saving
$ vim start vim from the command line
$ vim file_name.txt edit a file
i enter insert mode