Controlling Out-of-Domain Gaps in LLMs for Genre Classification and Generated Text Detection