Small fix for the correct use of the new `std_silent` decorator during Cython compilation
Replace test with `hasattr` for `is not None` in `std_silent.close`

Otherwise, we'll get an error if cleanup is performed and `std_silent` has never been used.