Only terminate server in shutdown hook. Fixes #144