Dispose the codegen even when just writing the bitcode file.

This makes it possible to add timers to the code generator and still use them
with -plugin-opt=emit-llvm.