Make server task end nicely