SPARK-2626 [DOCS] Stop SparkContext in all examples

Call SparkContext.stop() in all examples (and touch up minor nearby code style issues while at it)
You don't mean call close() but use try with resources ? That would require requiring Java 7.