cleanup function for plugins