To properly get rid of a map, it is not sufficient to remove it from the map manager. The map should also be removed from the UI.

The easiest way to make sure that you perform all necessary steps is to use the API equivalent of clicking the map Close button:

ILcyLucyEnv lucy = ...;
ILcyGenericMapComponent map = ...;

//Request the manager of the UI panels in Lucy
TLcyApplicationPaneManager applicationPaneManager = lucy.getUserInterfaceManager().getApplicationPaneManager();

//Ask the manager to discard the application pane of the map
//This will trigger all necessary clean-up code
applicationPaneManager.applyOnApplicationPane(map.getComponent(), ILcyApplicationPane::disposeApp);