Finally, stop the Spark session and H2O context. The following stop() method invocation will shut down the H2O context and Spark cluster, respectively:
h2oContext.stop(stopSparkContext = true)
spark.stop()
The first one, especially, is more important, otherwise it sometimes does not stop the H2O flow but still holds the computing resources.