Fix finalization bug and add stop_and_wait function

Fixes: https://github.com/saleyn/erlexec/issues/33 and https://github.com/saleyn/erlexec/issues/33