#2 extracted all safe-close methods to a separate utility