Added closeExistingWindow() to prevent an IllegalArgumentException

closes #299