How to play a sound or tone when a program ends?

Linking related post.