Now file is written when closing down as well.