No, this is not a valid JS command. What's happening is probably that the script throws an error (which you can see in the console), and exits. This is not a good way of doing it.
If your code is located in a function, you can use the return command to exit it. If it's not, you should place it in one...
That's a good way of doing it. There's no command in JS to just stop the execution of the script entirely.