Added cleanup

Close all files and writers