Fix saving of serialized data on shutdown