Get rid of Clang warning by casting switch value to integer
Fix hang on OS X by removing event source when process isn't running