Added cleanup routine to stop false closings