fixed server to stop hanging on exit