It depends on how you're sharing.
If you're using Steam's official Family Sharing feature, your friend will get a five-minute warning to save and exit before being kicked when you launch a game. That grace period is built in on purpose.
If instead you've handed out your actual Steam login details, which is against Steam's terms and a genuinely bad idea, then your friend will be booted immediately the moment you start playing. Sharing passwords also puts your account security at risk, so Family Sharing is always the safer route.