prevent undefined values in finally block

There is some copy pasta here from the `try` block. There is no way around this. The `finally` block should never ever depend on things defined in the `try` block because if there is an exception raised there there they will go undefined and the `finally` block will fail.