How can I bring a database offline safely?
Recently I took the database offline with the option Drop all active connections checked.

When you take a database OFFLINE, SQL Server is no longer protecting the database files from modification by other programs.  SQL Server tries to set file ACLs to prevent other users/programs from modifying the files, but having the database ONLINE provides an important additional protection.
Whenever possible perform actions in a way that doesn't take databases OFFLINE or stop the SQL Server service.  EG take the database to SINGLE USER mode instead of OFFLINE, and use Backup/Restore instead of moving database and databse files.
And if you do take the database OFFLINE, ensure that you have a backup first.