Implemented form terminate and added cancel