diff --git a/pkg/local_object_storage/writecache/mode.go b/pkg/local_object_storage/writecache/mode.go
index 20b0cce29..14f8af49e 100644
--- a/pkg/local_object_storage/writecache/mode.go
+++ b/pkg/local_object_storage/writecache/mode.go
@@ -29,9 +29,6 @@ func (c *cache) SetMode(m mode.Mode) error {
 		))
 	defer span.End()
 
-	c.modeMtx.Lock()
-	defer c.modeMtx.Unlock()
-
 	return c.setMode(ctx, m)
 }
 
@@ -40,13 +37,6 @@ func (c *cache) setMode(ctx context.Context, m mode.Mode) error {
 	var err error
 	turnOffMeta := m.NoMetabase()
 
-	if turnOffMeta && !c.mode.NoMetabase() {
-		err = c.flush(ctx, true)
-		if err != nil {
-			return err
-		}
-	}
-
 	if !c.initialized.Load() {
 		close(c.stopInitCh)
 
@@ -60,6 +50,16 @@ func (c *cache) setMode(ctx context.Context, m mode.Mode) error {
 		}()
 	}
 
+	c.modeMtx.Lock()
+	defer c.modeMtx.Unlock()
+
+	if turnOffMeta && !c.mode.NoMetabase() {
+		err = c.flush(ctx, true)
+		if err != nil {
+			return err
+		}
+	}
+
 	if c.db != nil {
 		if err = c.db.Close(); err != nil {
 			return fmt.Errorf("can't close write-cache database: %w", err)
diff --git a/pkg/local_object_storage/writecache/writecache.go b/pkg/local_object_storage/writecache/writecache.go
index 0fc2e601a..bdcc9bbf6 100644
--- a/pkg/local_object_storage/writecache/writecache.go
+++ b/pkg/local_object_storage/writecache/writecache.go
@@ -163,9 +163,6 @@ func (c *cache) Init() error {
 
 // Close closes db connection and stops services. Executes ObjectCounters.FlushAndClose op.
 func (c *cache) Close() error {
-	c.modeMtx.Lock()
-	defer c.modeMtx.Unlock()
-
 	// Finish all in-progress operations.
 	if err := c.setMode(context.TODO(), mode.ReadOnly); err != nil {
 		return err