Adding better signal handling

* better shutdown hooks with signals
* better handling of invalid processes