diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go
index b5c389111f8ed3ad33031332acc445e410b7d65f..76d71a6327bca609c79a72f57951f10f48e3341e 100644
--- a/cmd/ipfs/main.go
+++ b/cmd/ipfs/main.go
@@ -496,22 +496,24 @@ func (i *cmdInvocation) setupInterruptHandler() {
 			case <-ctx.InitDone:
 			}
 
-			// TODO cancel the command context instead
-
-			n, err := ctx.GetNode()
-			if err != nil {
-				log.Error(err)
-				fmt.Println(shutdownMessage)
-				os.Exit(-1)
-			}
-
 			switch count {
 			case 0:
 				fmt.Println(shutdownMessage)
-				go func() {
-					n.Close()
-					log.Info("Gracefully shut down.")
-				}()
+				if ctx.Online {
+					go func() {
+						// TODO cancel the command context instead
+						n, err := ctx.GetNode()
+						if err != nil {
+							log.Error(err)
+							fmt.Println(shutdownMessage)
+							os.Exit(-1)
+						}
+						n.Close()
+						log.Info("Gracefully shut down.")
+					}()
+				} else {
+					os.Exit(0)
+				}
 
 			default:
 				fmt.Println("Received another interrupt before graceful shutdown, terminating...")