diff --git a/cmd/peco/peco.go b/cmd/peco/peco.go
index <HASH>..<HASH> 100644
--- a/cmd/peco/peco.go
+++ b/cmd/peco/peco.go
@@ -81,27 +81,31 @@ func main() {
 		err = ctx.ReadConfig(opts.Rcfile)
 		if err != nil {
 			fmt.Fprintln(os.Stderr, err)
-			os.Exit(1)
+			ctx.ExitStatus = 1
+			return
 		}
 	}
 
 	if err = ctx.ReadBuffer(in); err != nil {
 		// Nothing to process, bail out
 		fmt.Fprintln(os.Stderr, "You must supply something to work with via filename or stdin")
-		os.Exit(1)
+		ctx.ExitStatus = 1
+		return
 	}
 
 	err = peco.TtyReady()
 	if err != nil {
 		fmt.Fprintln(os.Stderr, err)
-		os.Exit(1)
+		ctx.ExitStatus = 1
+		return
 	}
 	defer peco.TtyTerm()
 
 	err = termbox.Init()
 	if err != nil {
 		fmt.Fprintln(os.Stderr, err)
-		os.Exit(1)
+		ctx.ExitStatus = 1
+		return
 	}
 	defer termbox.Close()
Avoid using os.Exit()

os.Exit() effectively cancels all our defer's. If we have resources
being released there, this is a serious problem