Exception handling and shutdown around sending packets