[SPARK-4183] Close transport-related resources between SparkContexts

A leak of event loops may be causing test failures.
@tdas I have reverted the changes, though you can see from the fact that we have to do this that the API is not clean.