fixing splitting on spaces
removing debug print
properly exiting wait loop on forceful exit