Explicitly shut down server

Fix #519
Fix #520
Merge branch '0.9-maintenance'