Gently quit

If erlang quits (on mac at least since it runs "main" thread)
before the ports is closed, erlang exit and wx cleanup
both deletes memory from two threads which causes double deletes
and crashes when closing wings.

First close the window before, so the driver do not need do so much cleaning
and sleep a while before exiting, since the delete/destory is async.