Fix for mac (and cleaner code on windows). The server will now cleanly quit when Sublime shuts down or reloads the script.