Otherwise the task may be restarted during shutdown. Start the task in gst_vaapiencode_handle_frame() instead.