Wait for the player process to exit

Here’s a one-line fix to always wait for the player process, as discussed in Issue #234. Also included is a fix to close a non-Windows named pipe to avoid deadlocking, and a better version of one of my earlier ResourceWarning fixes.

I suspect no equivalent fix for the Windows named pipe is needed, but I haven’t tested it. However, reading the documentation it looks like you should probably be calling FlushFileBuffers() before DisconnectNamedPipe(), and CloseHandle() afterwards.