I am having an issue where the SendMessage() function is causing a script to hang and thus never exiting though it is running the SendMessage like it should (Its task comple
Change SendMessage to PostMessage. It worked for me.
SendMessage
PostMessage
The difference is that PostMessage is asynchronous and it doesn't have to wait for any response.