Refactored close invocation