improve close function and add generate chart image task