Close the VM port when terminating the VM

* the VM thread should handle its own termination, so use postVMEvent().
Move VM termination definitions to boostenv.cc