Don't mask setup errors

`_post_teardown()` always happens, and sometimes the `app` and/or `_ctx` attributes don't exist anymore. This triggers an `AttributeError` exception, which masks whatever the original exception was. Using `getattr()` allows the `AttributeError` to be avoided.