Fix some python shutdown / ordering issues.

Differential Revision: http://reviews.llvm.org/D4826

Reviewed by: Enrico Granata