diff --git a/experimental/custom-metrics-api/gencerts.sh b/experimental/custom-metrics-api/gencerts.sh
index b1e16031ff40fe5b74b278fb27a95e67bc0cd307..a8f5539d90725d3b4cbc59b540834e4b8046a7b4 100755
--- a/experimental/custom-metrics-api/gencerts.sh
+++ b/experimental/custom-metrics-api/gencerts.sh
@@ -1,4 +1,10 @@
 #!/usr/bin/env bash
+# exit immediately when a command fails
+set -e
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
+# error on unset variables
+set -u
 
 # Detect if we are on mac or should use GNU base64 options
 case $(uname) in
diff --git a/hack/example-service-monitoring/deploy b/hack/example-service-monitoring/deploy
index 4912dd9658d18db27dba7e900a08edb0b03ed1b1..0c7cd7c1a4632240478354f51f3aaead0ff0f990 100755
--- a/hack/example-service-monitoring/deploy
+++ b/hack/example-service-monitoring/deploy
@@ -1,3 +1,9 @@
 #!/usr/bin/env bash
+# exit immediately when a command fails
+set -e
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
+# error on unset variables
+set -u
 
 kubectl apply -f examples/example-app
diff --git a/hack/example-service-monitoring/teardown b/hack/example-service-monitoring/teardown
index 62b546dea28c9d8519059b1f49beff49fabc38f0..1a49f4625cf5378b091762900c0d791e46a93095 100755
--- a/hack/example-service-monitoring/teardown
+++ b/hack/example-service-monitoring/teardown
@@ -1,3 +1,9 @@
 #!/usr/bin/env bash
+# exit immediately when a command fails
+set -e
+# only exit with zero if all commands of the pipeline exit successfully
+set -o pipefail
+# error on unset variables
+set -u
 
 kubectl delete -f examples/example-app