Also exit the longpolling loop if shutdown was requested
Add test for getblocktemplate longpolling