Write to the database when the module unloads