For security reasons, most browsers won't allow you to close a window with javascript that you didn't first open with javascript earlier in the session.
To add that call to the button you could add an onclick event like: <img onclick="window.close()" src="...