better shutdown behaviour and better logging