Use EPartService.hidePart(MPart)
or hidePart(MPart, boolean)
.
hidePart(MPart)
normally just hides the part but if the removeOnHide
value is set in the part Tags then it is also deleted.
hidePart(MPart, true)
lets you force the delete regardless of the tags.
Edit:
To close the window call MWindow.setToBeRendered(false)
the window will remain in the application model but resources etc. will be disposed.