Add util method to close IO streams