form closed at the wrong place