Free window object on shell destruction

Fix #1364
Force close the new-instance window