type ESC, SHIFT + ;, x and hit ENTER

read more: Stack Overflow: Helping One Million Developers Exit Vim

Still stuck? Try https://stuckinvim.com/

...alternatively, TheMsDosNerd suggests:

CTRL + [, SHIFT + ;, q, SHIFT + 1, ENTER

Reasons to use vim

  • Lifting your hand off the keyboard to use the mouse and then switching back repeatedly is tedious and can lead to cramps. Ever get tired of typing then clumsily selecting a menu option with your mouse? See Fitt's law
  • vim's motion operators are much more intuitive and feature-rich than standard keyboard shortcuts
  • vim is lightweight; you don't need to wait ages for your IDE to start up then have it hog resources as it idles in the background
  • Configuring vim is easy. You either add a few lines to .vimrc or drop a plugin into .vim/bundle using Pathogen. No more wading through dense IDE configuration
  • Multiselection has never been easier. Do you use search and replace and regex to insert something before a set of lines? Stop right now and learn about the magic of Ctrl+v

I'm a masochist. What's the quickest way to close vim in my favorite programming language?

codegolf.se has you covered

Python 2, 66 bytes

Saved 3 bytes thanks to @Mr.Xcoder and 4 thanks to @Mayube!
from random import*
if'('in input(':q'):print choice([':x',':q!'])