I think it would be easier to include a button on the web page that pops up a window that contains the applet. In the popup window you can have a button that closes the window.
You can see an example on the Web at
http://www.nhn.ou.edu/~walkup/demonstrations/WebAssignments/HarmonicMotion001E.htm . Notice that the "Applet Help" button pops up a window containing some text and a "Close" button. The "Open Applet" button, on the other hand, pops up a window containing an applet. Installing a similar "Close" button on the applet window would be very easy.
Try it and see if this is the kind of functionality you are looking for.