When you've made no changes to a file and simply want to quit, type:
:q |
followed by Return. If you have made changes, vi will not let you quit with :q. Instead, it will display the message, No write since last change (:quit! overrides).
If you do not want to save your changes, type:
:q! |