fixed shutdown function to wait for existing experiments