You can only close a window with JavaScript that has been opened with JavaScript. Since you went with an HTML method, this won't work.
However, if you were to re-code so that JavaScript was opening the window instead...
mylink
Then you could close the resulting window with JavaScript.