Added more resources to close method call and formatted json writer.