wait function for writing screenshot.