I assume you're using the simulator to simulate future moves and it occurs on the line where you access the task in the dictionary containing action-successor board pair.
In case that is true, read on, else ignore this post. Essentially, there are a set of invalid occurrences that can happen when you simulate a board.
1. It generates a successor board, with the correct action as the key that you had applied for testing (correct case)
2. It generates a null board, but the key is the correct action that you had applied for testing (invalid case)
3. It generates a null board, and the key is not even the one you had applied for testing (another invalid case)
4. It might also happen that it generates a valid successor board, with a key that you didn't apply (would be an invalid case, I didn't particularly care about this so I didn't check)
So you can add checks for validity, like if dictionary contains the action you had applied, and checks like if the board state is null, do something.
Does this happen roughly around the same time as when you check it? Did you try pausing it in this state to see which line it was stuck on? For my case, it sometimes happens that when i scroll up the console to look up the results, it sometimes gets stuck in the write console line... Wasn't debilitating enough for me to consider looking for a solution...