Plug-ins that are loaded into Maya should be unloaded before they can be recompiled. If the plug-in uses dynamic libraries, it must be unloaded before it is recompiled otherwise Maya will crash. It is good practice to always unload a plug-in before rebuilding it.
Make sure that the plug-in is not in use before you unload it. Make sure that there are no references to the plug-in anywhere in the scene, including in the undo queue. Use the flushUndo command to flush the undo queue.
Note: Flushing the undo queue removes all information from the undo queue. It effectively deletes the entire undo queue.
Once there are no longer any references to the plug-in in Maya, you can unload it using the unloadPlugin command.
If a reference to it still exists, you will get an error when you attempt to unload the plug-in: