diff --git a/lxd/cluster/heartbeat.go b/lxd/cluster/heartbeat.go
index <HASH>..<HASH> 100644
--- a/lxd/cluster/heartbeat.go
+++ b/lxd/cluster/heartbeat.go
@@ -150,7 +150,11 @@ func (hbState *APIHeartbeat) Send(ctx context.Context, networkCert *shared.CertI
 			spreadRange := spreadDurationMs - 3000
 
 			if spreadRange > 0 {
-				time.Sleep(time.Duration(rand.Intn(spreadRange)) * time.Millisecond)
+				select {
+				case <-time.After(time.Duration(rand.Intn(spreadRange)) * time.Millisecond):
+				case <-ctx.Done():
+					return
+				}
 			}
 		}
lxd/cluster/heartbeat: Cancel APIHeartbeat Send during spread sleep if context is cancelled