Ensure monitor is closed after task is resumed, fixes #121.