Remove history when window closed

Thanks for patch to Bill Rushmore
Fix perltidy test