Refactor: tryClose() method