Implement chunk saving on exit. Close #2.