Properly close resource streams in html report generation to ensure report has images before applications closes and streams are flushed