It depends on the browser - most browser don't allow this or at least ask the user for confirmation. Some allow that you can only reliably close a window by Javascript that was previously opened by JavaScript.
Besides not recommending it, but I personally don't see the advantage of it. Users of a browser usually know how to close a window (depending on ther Operating system), so you would add a function that the browser itself already offers, is easily accesible and most users will know how to use it.
Help us to help you!
Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.