TOKYO -- Residents in western Japan were cleaning up debris Monday evening after a powerful earthquake hit the area around Osaka, the country's second-largest city, killing four people and injuring hundreds while knocking over walls and setting off fires. The magnitude 6.1 earthquake that struck the area early Monday damaged buildings and left many homes without water or gas. The quake also grounded flights in and out of Osaka and paralyzed traffic and commuter trains most of the day.

By evening, bullet trains and some local trains had resumed operation, and stations were swollen with commuters trying to get home, many of them waiting in long lines. An exodus of commuters who chose to walk home filled sidewalks and bridges.

Some commuters took refuge in nearby shelters instead of going home. NHK public television showed dozens of men wearing ties and carrying briefcases sitting on gym mats at a junior high school gymnasium in Ibaraki city, where some families also gathered.

Water flows out from cracks in a road damaged by an earthquake in Takatsuki, Osaka prefecture, western Japan, in this photo taken by Kyodo on June 18, 2018. Reuters

Takatsuki city confirmed another victim late Monday, as the death toll rose to four. City officials didn't have details of the victim, but NHK and Kyodo News reported that an 81-year-old woman was found dead underneath a wardrobe that fell on her at her home in Takatsuki.

Get Breaking News Delivered to Your Inbox

Also in Takatsuki, a concrete wall at an elementary school fell onto the street, killing 9-year-old Rina Miyake as she walked to the school. NHK showed the collapsed upper half of the high wall, which was painted cheerfully with flowers, trees and blue sky and surrounded the school swimming pool.

A police officer stands guard at the site where a girl was killed by fallen wall caused by an earthquake at an elementary school in Takatsuki, Osaka prefecture, western Japan, in this photo taken by Kyodo on Mon., June 18, 2018. Reuters

Mayor Takeshi Hamada apologized over her death because of the wall's collapse. The city acknowledged that the wall did not meet building safety codes. The structure was old and made of concrete blocks - a known risk in earthquakes. Chief Cabinet Secretary Yoshihide Suga ordered the Education Ministry to conduct nationwide safety checks of concrete block structures at public schools.

More than 1,000 schools were closed in Osaka and nearby prefectures, Kyodo News reported. Wall cracks and other minor damage were found at several schools.

A man in his 80s died in the collapse of a concrete wall in Osaka city. An 85-year-old man in nearby Ibaraki died after a bookcase fell on top of him at home, according to the disaster management agency.

BBC News cites officials who say another tremor could happen in the next few days.

The Fire and Disaster Management Agency said 307 people were treated for injuries at hospitals. Most of the injured were in Osaka. Osaka officials did not give details, but the injuries reported in Kyoto and three other neighboring prefectures were all minor.

BBC News also notes that several key industrial areas near Osaka were affected. Companies like Panasonic and Daihatsu are suspending production at their affected sites.

The quake struck shortly before 8 a.m. north of Osaka at a depth of about 13 kilometers (8 miles), the Japan Meteorological Agency said. The strongest shaking was north of Osaka, but the quake rattled large parts of western Japan, including Kyoto, the agency said.

Dozens of domestic flights in and out of Osaka were grounded, while train and subway service in the Osaka area, including bullet trains, was suspended to check for damage. Passengers exited trains on the tracks between stations.

Train guide electric boards tilt following an earthquake at Ibaraki-shi Station in Ibaraki City, north of Osaka prefecture on June 18, 2018. Getty

Some subway service resumed in the afternoon, but stations remained crowded with passengers waiting for trains to restart, many of them sitting on the floor. Long lines of people waited to board bullet trains as they resumed operation.

Some manufacturers, including automakers Daihatsu Motor Co. and Honda Motor Co., electronics makers Panasonic and Sharp Corp., and confectioners Ezaki Glico Co. and Meiji Co., temporarily stopped production lines at their factories in the region for safety checks, news reports said.

The quake knocked over walls, broke windows and set off scattered building fires. It toppled furniture in homes and goods onto shop floors. It also cracked roads and broke water pipes, leaving homes without water.

Many homes and buildings, including a major hospital, were temporarily without power, though electricity was restored at most places by midafternoon.

Due to damage to underground gas lines, 110,000 homes in Takatsuki and Ibaraki cities were without gas, and repairs are expected to take as long as two weeks, according to Osaka Gas Co.

More building damage was found in the afternoon as disaster and relief workers inspected and cleaned up the affected areas. Roofs and roof tiles at homes and at least one temple fell to the ground in Osaka. At a shrine in Kyoto, stone lanterns broke and collapsed to the ground.

Defense troops joined rescue and relief operations in parts of Osaka, along with special vehicles to deliver clean drinking water.

Residents cleaned up debris at home and stores throughout the day. Meteorological agency officials warned of strong aftershocks in the area, urging residents to stay away from damaged structures.

The earthquake reminded many of the magnitude 7.3 Kobe quake in 1995 that killed more than 6,000 people in the region. Monday's quake also followed a series of smaller quakes near Tokyo in recent weeks. Japan's northern prefectures are still recovering from a magnitude 9.0 quake and tsunami in 2011 that killed more than 18,000.

"It was not as bad as the Kobe quake," said Jun Kawanami, a 30-year-old lawyer in Osaka. He said his wife ducked under a table and elevators in his office building were out of operation. "I used the stairs but I was out of breath by the time I arrived at my office on the 22nd floor," he said.