Reinstate the datastore flush at exit fix