Ensure close is called in all scenarios and switch to using{} for Dispose