I've determined that the variable, someOtherObject, is returning a null object. So when the doStuff() method is called, an exception is thrown. However, the finally block is immediately fired once this exception happens; and inside the finally block, the TypeError is thrown because csv has not been initialized in the try block yet.
This latter error is the only one that gets shown however, which was the source of confusion. Once I resolved the issue with someOtherObject, the code worked. (I've also added guards around the close method to make sure that csv is initialized).