// Exit Ctrl + (C | D | Z) and alike handler
438246
func (list *List) Exit() {

	// Should go down to the last option
	for list.Index != len(list.options) {
		list.Index++
		list.Cursor.MoveDown(1)
	}

	list.Println()
	list.Println()
	list.Print(ShowCursor)

	os.Exit(1)
}
137596
func (h handler) Stop(ctx *Context) {
	ctx.Stopped = true
	h.next(ctx)
}
518358
func (pc *paramMarkerInPrepareChecker) Leave(in ast.Node) (out ast.Node, ok bool) {
	return in, true
}
1135485
func (f *Queries) Escape(key string) (string, error) {
	s, err := f.String(key)
	if err != nil {
		return "", err
	}
	return template.HTMLEscapeString(s), nil
}
1144197
func (e *ExecIO) Close() error {
	if e.closer != nil {
		e.closer.Close()
	}
	if e.fifos != nil {
		return e.fifos.Close()
	}
	return nil
}
268356
func (t *Terminal) handleKey(key rune) (line string, ok bool) {
	if t.pasteActive && key != keyEnter {
		t.addKeyToLine(key)
		return
	}

	switch key {
	case keyBackspace:
		if t.pos == 0 {
			return
		}
		t.eraseNPreviousChars(1)
	case keyAltLeft:
		// move left by a word.
		t.pos -= t.countToLeftWord()
		t.moveCursorToPos(t.pos)
	case keyAltRight:
		// move right by a word.
		t.pos += t.countToRightWord()
		t.moveCursorToPos(t.pos)
	case keyLeft:
		if t.pos == 0 {
			return
		}
		t.pos--
		t.moveCursorToPos(t.pos)
	case keyRight:
		if t.pos == len(t.line) {
			return
		}
		t.pos++
		t.moveCursorToPos(t.pos)
	case keyHome:
		if t.pos == 0 {
			return
		}
		t.pos = 0
		t.moveCursorToPos(t.pos)
	case keyEnd:
		if t.pos == len(t.line) {
			return
		}
		t.pos = len(t.line)
		t.moveCursorToPos(t.pos)
	case keyUp:
		entry, ok := t.history.NthPreviousEntry(t.historyIndex + 1)
		if !ok {
			return "", false
		}
		if t.historyIndex == -1 {
			t.historyPending = string(t.line)
		}
		t.historyIndex++
		runes := []rune(entry)
		t.setLine(runes, len(runes))
	case keyDown:
		switch t.historyIndex {
		case -1:
			return
		case 0:
			runes := []rune(t.historyPending)
			t.setLine(runes, len(runes))
			t.historyIndex--
		default:
			entry, ok := t.history.NthPreviousEntry(t.historyIndex - 1)
			if ok {
				t.historyIndex--
				runes := []rune(entry)
				t.setLine(runes, len(runes))
			}
		}
	case keyEnter:
		t.moveCursorToPos(len(t.line))
		t.queue([]rune("\r\n"))
		line = string(t.line)
		ok = true
		t.line = t.line[:0]
		t.pos = 0
		t.cursorX = 0
		t.cursorY = 0
		t.maxLine = 0
	case keyDeleteWord:
		// Delete zero or more spaces and then one or more characters.
		t.eraseNPreviousChars(t.countToLeftWord())
	case keyDeleteLine:
		// Delete everything from the current cursor position to the
		// end of line.
		for i := t.pos; i < len(t.line); i++ {
			t.queue(space)
			t.advanceCursor(1)
		}
		t.line = t.line[:t.pos]
		t.moveCursorToPos(t.pos)
	case keyCtrlD:
		// Erase the character under the current position.
		// The EOF case when the line is empty is handled in
		// readLine().
		if t.pos < len(t.line) {
			t.pos++
			t.eraseNPreviousChars(1)
		}
	case keyCtrlU:
		t.eraseNPreviousChars(t.pos)
	case keyClearScreen:
		// Erases the screen and moves the cursor to the home position.
		t.queue([]rune("\x1b[2J\x1b[H"))
		t.queue(t.prompt)
		t.cursorX, t.cursorY = 0, 0
		t.advanceCursor(visualLength(t.prompt))
		t.setLine(t.line, t.pos)
	default:
		if t.AutoCompleteCallback != nil {
			prefix := string(t.line[:t.pos])
			suffix := string(t.line[t.pos:])

			t.lock.Unlock()
			newLine, newPos, completeOk := t.AutoCompleteCallback(prefix+suffix, len(prefix), key)
			t.lock.Lock()

			if completeOk {
				t.setLine([]rune(newLine), utf8.RuneCount([]byte(newLine)[:newPos]))
				return
			}
		}
		if !isPrintable(key) {
			return
		}
		if len(t.line) == maxLineLength {
			return
		}
		t.addKeyToLine(key)
	}
	return
}
80372
func Exit(code int) {
	// check if there was a panic
	if x := recover(); x != nil {
		var (
			offset int = 3
			pc     uintptr
			ok     bool
		)
		log.Printf("run time panic: %v", x)
		for offset < 32 {
			pc, _, _, ok = runtime.Caller(offset)
			if !ok {
				// close with an error
				c.closeErr()
				return
			}
			frame := newStackFrame(pc)
			fmt.Print(frame.String())
			offset++
		}
		// close with an error
		c.closeErr()
		return
	}
	if code == ExitCodeOK {
		c.closeOnce.Do(func() {
			close(c.closeChan)
		})
		<-c.doneChan
		return
	}
	c.closeErr()
}
1304919
func ExitStatus(err error) int {
	if err == nil {
		return 0
	}

	code := 1
	if exiterr, ok := err.(*exec.ExitError); ok {
		if waitStatus, ok := exiterr.Sys().(syscall.WaitStatus); ok {
			code = waitStatus.ExitStatus()
		}
	}
	return code
}
682927
func (mvcc *MVCCLevelDB) Cleanup(key []byte, startTS uint64) error {
	mvcc.mu.Lock()
	defer mvcc.mu.Unlock()

	batch := &leveldb.Batch{}
	err := rollbackKey(mvcc.db, batch, key, startTS)
	if err != nil {
		return errors.Trace(err)
	}
	return mvcc.db.Write(batch, nil)
}
65882
func (c context) stop() error {
	// Stop app
	appExitResult, appExitErr := command.Exec(c.config.keybasePath(), []string{"ctl", "app-exit"}, 30*time.Second, c.log)
	c.log.Infof("Stop output: %s", appExitResult.CombinedOutput())
	if appExitErr != nil {
		c.log.Warningf("Error requesting app exit: %s", appExitErr)
	}

	// Stop the redirector so it can be upgraded for all users.
	_, redirectorErr := command.Exec(c.config.keybasePath(), []string{"uninstall", "--components=redirector"}, time.Minute, c.log)
	if redirectorErr != nil {
		c.log.Warningf("Error stopping the redirector: %s", redirectorErr)
	}

	// Stop services
	servicesExitResult, servicesExitErr := command.Exec(c.config.keybasePath(), []string{"ctl", "stop", "--include=service,kbfs"}, 30*time.Second, c.log)
	c.log.Infof("Stop output: %s", servicesExitResult.CombinedOutput())
	if servicesExitErr != nil {
		c.log.Warningf("Error stopping services: %s", servicesExitErr)
	}

	paths, err := c.lookupProcessPaths()
	if err != nil {
		return err
	}

	// SIGKILL the app if it failed to exit (if it exited, then this doesn't do anything)
	c.log.Infof("Killing (if failed to exit) %s", paths.appProcPath)
	process.KillAll(process.NewMatcher(paths.appProcPath, process.PathContains, c.log), c.log)

	return nil
}
1143763
func (exec *TabletExecutor) Close() {
	if !exec.isClosed {
		exec.tablets = nil
		exec.isClosed = true
	}
}
837213
func (pb *paramsBuffer) End() string {
	s := pb.out.String()
	pb.lk.Unlock()
	return s
}
561852
func (a *Astilectron) Quit() error {
	return a.writer.write(Event{Name: EventNameAppCmdQuit})
}
1007428
func (c *Conn) CloseHandler() func(code int, text string) error {
	return c.handleClose
}
600599
func ExitDepth(depth int, args ...interface{}) {
	zap.S().Error(args...)
	os.Exit(1)
}
257806
func (m *mapReact) Close() {
	m.ro.RLock()
	for ms, ok := range m.ma {
		if !ok {
			continue
		}
		ms.Close()
	}
	m.ro.RUnlock()
	m.Clean()
}
656420
func (p *Process) Delete(ctx context.Context) (*runtime.Exit, error) {
	r, err := p.t.shim.DeleteProcess(ctx, &shim.DeleteProcessRequest{
		ID: p.id,
	})
	if err != nil {
		return nil, errdefs.FromGRPC(err)
	}
	return &runtime.Exit{
		Status:    r.ExitStatus,
		Timestamp: r.ExitedAt,
		Pid:       r.Pid,
	}, nil
}